Jump to content

checking the array


karthikanov24

Recommended Posts

hi

$child  = array_merge($child, getChildCategories($categories, $catId));

 

In the above line of code,the value(return value) of the function getChildCategories() is an array....

how to check(what debugging code is used) whether there is any value or in that function(or array) or it is null....?

 

 

thanks

karthikanov24

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/
Share on other sites

It being on the same line or not will make absolutely no difference. I would however recommend using curly brackets even if you only have a single lines, it helps limit errors creeping into code.

 

its only 1 line after no brackets that gets executed am i right ?

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/#findComment-949479
Share on other sites

Without curly braces only the first 'line' of code following the statement will be done as part of the statement. But whitespace doesn't make the slightest bit of difference.

 

// this
if(true) 

   echo "True";

else 

echo "False";

// is exactly the same as this
if(true) echo "True";
else echo "False";

I would always recommend a variation of this as the 'correct' way of doing it. Otherwise you can introduce problems when you complicate things.

 

if(true) {
   echo "True";
} else {
   echo "False";
}

Link to comment
https://forums.phpfreaks.com/topic/179979-checking-the-array/#findComment-949498
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.