0
if
(
  ($page_num >=10 && $page_num<= 20)  || 
  ($page_num >= 21 && $page_num =< 30) || 
  ($page_num >=31 && $page_num =<40)
){
     if($i==1){
       $i = $page_num;
     }
 }

I am trying to achieve multiple conditionals using the above in PHP. I tried it and it kept outputting an error, so I don't know if I am making a mistake or what I am trying above is not possible in PHP or programming.

The error message

Parse error: syntax error, unexpected '<' in C:addsdcredit.php on line 398

1
  • 4
    Isn't this the same as $page_num >= 10 && $page_num <= 40? Why do you need 3 conditions? Commented May 31, 2018 at 16:36

1 Answer 1

3

You have =< on your code, change them like this: <= . check http://php.net/manual/fa/language.operators.precedence.php. Hope it helps.

$page_num = 11;
$i=1;
if(($page_num >=10 && $page_num<= 20)  || ($page_num >= 21 && $page_num <= 30) || ($page_num >=31 && $page_num <=40)){
     if($i==1){
       $i = $page_num;
       }
 }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.