0

I have a small issue with my script.

I'm getting Strict Standards: Only variables should be passed by reference in

if( $checkDNS && ($domain = end(explode('@',$email, 2))) )
asked Jan 21, 2013 at 22:24
1

3 Answers 3

3

From the PHP manual:

This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

So you must use a variable in the end function:

$domain = explode('@',$email, 2);
if( $checkDNS && ($domain = end($domain)) )
answered Jan 21, 2013 at 22:28
Sign up to request clarification or add additional context in comments.

Comments

2

From the manual:

mixed end ( array &$array )

end takes the array by reference and move the internal pointer. Your array is the function output, so its unable to correctly modify the array by reference.

answered Jan 21, 2013 at 22:27

Comments

0

Like the message says, end expects a variable because its parameter is a reference.

But since PHP 5.4 you can dereference arrays like that:

$domain = explode('@',$email, 2)[1];

Assuming that $email always contains @. You should assure that beforehand, otherwise end(...) would give you unexpected results too.

answered Jan 21, 2013 at 22:33

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.