3

When i'm using following code then fatal error generate.

echo empty(is_resource(true));

Error:

Fatal error: Can't use function return value in write context.

Why?

1 Answer 1

8

empty requires a variable as if the parameter were passed by reference:

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

So you could do this:

$var = is_resource(true);
echo empty($var);

But as is_resource already returns a boolean value, you actually don’t need another testing function.

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.