开发者

OR in if condition raises "unexpected T_VARIABLE" error [closed]

It's difficult to tell what is being asked here. Thi开发者_如何转开发s question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

I'm stuck. I just want a simple OR inside an if condition and php always raises an error:

My Code:

if( ($value > 0.01 || $seconds < 100) ):

Error:

Parse error: syntax error, unexpected T_VARIABLE


I've been struggling with the same problem, and now I finally decided to get to the bottom of it. Turns out the space character that I had after the || operator isn't actually space (= %20), it's %A0 (no idea how that happened). I'm using gEdit on Ubuntu, seems like Windows/Notepad treats them both as regular space.

So the lesson here is, check that your characters really are what you think they are.


change your code into this:

if(($value > 0.01)||($seconds < 100))
{

}

hope it works! :)


You need to provide more code, The following code works at my computer:

<?php
$value = 2;
$seconds = 10;
if( ($value > 0.01 || $seconds < 100) ) {
  echo("OK");
} else {
  echo("fail");
}
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜