7

the page code is all html and it wont load bec. of this error:

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

code:

<div>
    <div class="">
        <input type="text" id="select_shelves" name="select_shelves" class="shelves_select_and_buttons" />
        <div id="shelves_menu" >
            <ul>
                <li id="li_" onclick="printValue();">option5 <= line 142 </li>
            </ul>
        </div>
    </div>
    <div class="button">
        <input type="button" onclick="dropShelves();" id="Shelves_select_button" name="Shelves_select_button" value="" class="grey_button"/>
    </div>
</div>
6
  • 2
    Are those functions PHP? Commented Apr 18, 2011 at 13:13
  • 4
    Is this really php, this just looks like html + javascript Commented Apr 18, 2011 at 13:14
  • 1
    I don't think the question is clear enough as you posted it. Also why did you tag the question PHP? Wouldn't HTML and Javascript be more suitable? Commented Apr 18, 2011 at 13:16
  • The error is thrown by doing something like foo() = 'something'. Perhaps you're comparing with = instead of ==...? Commented Apr 18, 2011 at 13:17
  • What are you trying to do with those edits? Please use the comment system to explain your question. Commented Apr 18, 2011 at 13:22

2 Answers 2

32

If there is some PHP behind, the problem could be calling a function empty($var) in this way:

if(empty($var = getMyVar())) { ... }

Instead of this You should call it this way:

$var = getMyVar();
if(empty($var)) { ... }

Or better (as deceze has pointed out)

if(!getMyVar()) { ... }

Problem causes also other similar functions (isset, is_a, is_null, etc).

Sign up to request clarification or add additional context in comments.

8 Comments

Again, this will not throw the Can't use function return value in write context (on 5.3, it'll throw a syntax error)...
there is no php code just html
@bm2001: if there is only HTML code, what is throwing you that error??? and why did you tag the question PHP?
Just do if (!getMyVar()). No empty needed at all.
|
14

you are probably using something like:

if(empty(urFunc($foo)){
    ....
}

which won't work.

what ever it is (look for the lien number in the error to locate it) change it to:

$foo = urFunc($bar);
if(empty($foo)){
    ....
}

that should fix it.

8 Comments

That will not generate that error. The error you'd get would be different (there would be an error though)...
erm... I was fairly sure it that it will (forums.devshed.com/php-development-5/…)
I would suggest to reply to @ircmaxell like this since otherwise he won't get notified I think...
What you really want is if (!urFunc($bar)). No empty needed at all.
@KevinVanRyckegem php.net/manual/en/function.empty.php - priorto 5.5 you could only use it on variables.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.