Archive for the ‘PHP’ Category

PHP short-hand IF/Else statement

Share/Save

Let’s keep it simple:

Regular way:

if (statement) {
  $variable = "return this if true";
}
else {
  $variable = "return this if false";
}

Short way:

$variable = (statement) ? "return if true" : "return if false";

And this is how it works: statement ? if-true : if-false

Apache – display server errors on screen

Share/Save

Let’s say that you are developing in PHP and something goes wrong and you end with a blank page instead of the expecting php page… great! what happened, where is the error?

(more…)

Get the top parent page in Wordpress

Share/Save

A couple of days ago I found myself with the issue of getting the top parent of any page (that one which doesn’t have any father), so after look in Wordpress documentation I found a nice function called get_page_hierarchy() and also no documentation about it. (more…)