RE: syntax question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I'm a beginner with php and i'm following up after a programmer that
> tried to install the geoip php api on our website(but not quite
> successfully).  I'm confused about what he was trying to do with this
> piece of code, specifically the following portion:
> 
> if ($_REQUEST["geocountry"]<>"")
> 
> 
> 
> short context:
> 
> if ($_REQUEST["geocountry"]<>""){
> $_SESSION['geocountry']= $_REQUEST["geocountry"];
> $_SESSION['geocountryId']=$_REQUEST["geocountry"];
> 
> }
> 
> I realize this is probably very simple, but I can't seem to find the
> answer.
> 
> thank you in advance,

PHP uses C syntax, not a BASIC syntax, so the "not equal" operator is != and
not <>

Also, for string comparisons, you should use strcmp, but when comparing to
an empty string or null, you should use empty() or isset().  So, your code
might look like this:


// note: isset will tell you if the "geocountry" value is set in the
REQUEST.
if (isset($_REQUEST["geocountry"])){
  $_SESSION['geocountry']= $_REQUEST["geocountry"];
  $_SESSION['geocountryId']=$_REQUEST["geocountry"];
}

-D. Israel
dan@xxxxxxxx
http://www.customcodebydan.com 
AIM: JudoDanIzz

A BANDAID!? Damn it Jim,I'm a doctor,not a-oh, never mind


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux