Reputation: 859
The following code show some function called as parameter to another function:
$somevar = count(substr(time(),0,10));
echo $somevar;
Does the innermost function gets executed first?
Upvotes: 2
Views: 54
Reputation: 76666
Yes. The above code translates to the following:
$timestamp = time();
$first_ten_chars = substr($timestamp ,0 , 10);
$somevar = count($first_ten_chars);
However, the code doesn't really make much sense. time()
returns a Unix timestamp, and it will have (most likely have) 10 characters (unless you're talking about a date that's 273+ years from now), so the substr()
function will just return the entire timestamp. count()
counts the number of elements in an array / object, and since you're passing a string, it will always return 1
.
If you state what you're trying to do, I may be able to suggest the correct way of doing it.
Upvotes: 5