If statement structure in PHP

I keep getting an error with the following bit of code. It is probably some small thing but I don't see what is wrong.

while($row = mysql_fetch_array($result))
  {
   $varp = $row['ustk_retail'];
   if ($varp<80000) { $o1 = 1; }
   if (($varp=>80000) && ($varp<100000)) { $o2 = "1"; }
   if (($varp=>100000) && ($varp<120000)) { $o3 = "1"; }
   if (($varp=>120000) && ($varp<140000)) { $o4 = "1"; }
   if (($varp=>140000) && ($varp<160000)) { $o5 = "1"; }
   if (($varp=>160000) && ($varp<180000)) { $o6 = "1"; }
   if (($varp=>180000) && ($varp<200000)) { $o7 = "1"; }
   if (($varp=>200000) && ($varp<220000)) { $o8 = "1"; }
   if (($varp=>220000) && ($varp<240000)) { $o9 = "1"; }
   if (($varp=>240000) && ($varp<260000)) { $o10 = "1"; }
   if (($varp=>260000) && ($varp<280000)) { $o11 = "1"; }
   if (($varp=>280000) && ($varp<300000)) { $o12 = "1"; }
   if ($varp>=300000) { $o13 = "1"; }
  }

Greater than or equal to is >= sign, not =>

Update:
You are right. It's small but hard to find mistake.
It took me to split whole line into pieces to see where the problem is:

<?php
if 
(
$varp
=>
80000
)

So, it says parse error on line 5 and I had to doublecheck this operator.
Of course, at first I separated the problem line from the rest of the code to be certain.


Running php -l (lint) on your code I get a

Parse error: syntax error, unexpected T_DOUBLE_ARROW

The T_DOUBLE_ARROW token is what PHP expects when assigning array values to array keys.

When comparing for Greater than or equal to the PHP Parser expects T_IS_GREATER_OR_EQUAL , meaning you have to use >= instead of => .

See

  • the chapter on Comparison Operators in the PHP Manual and
  • the List of Parser Tokens in the PHP Manual

  • 你有一个表达错误。

    $varp=>220000 // is not a valid php expression
    
    => operator is used to assign values in arrays like:
    
    $x = array( 'foo' => 'bar');
    
    >= is the comparation assigment greater than or equal
    
    链接地址: http://www.djcxy.com/p/12034.html

    上一篇: 如何检查文本框是否为空并且值小于500

    下一篇: 如果PHP中的语句结构