PHP: Erratic behaviour of functions?
What on earth is PHP doing here?
This first line works perfectly, but when I try to check whether the return of the parse_url
is empty or not, my whole execution is stopped and the infamous White screen appears:
Working:
$subFolderCheck = ( strlen( parse_url('http://www.example.com', PHP_URL_PATH)) >1 ? true : false);
Making开发者_运维问答 my script go bananas:
$subFolderCheck = ( empty( parse_url('http://www.example.com', PHP_URL_PATH)) ? true : false);
Here it is explained.
you can not call a function inside empty function
Note:
empty() only checks variables as anything else will result in a parse error. In other words, the following will not work: empty(trim($name)).
You could assign the return value in variable and check that variable with empty
$subFolderCheck=(parse_url('http://www.example.com', PHP_URL_PATH)) ? true : false);
if (empty($subFolderCheck))
{
//do stuff
}
精彩评论