0

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);

1 Answer 1

4

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
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.