[FX.php List] if ( $var != '' ) OR if ( !empty($var) ) -- gen'l
php recommendations?
Joel Shapiro
jsfmp at earthlink.net
Mon Jul 24 19:52:02 MDT 2006
Thanks Steve
I've checked out php.net on this now, as well as previous threads
here on error_reporting.
I've put error_reporting(E_ALL); on my detail page, just below
session_start();
Since I've put this on my page, it seems I don't need to change my
php.ini file.
Will I need to set anything regarding display_errors?
How can I test this (so I can see some errors displayed)?
Best,
-Joel
On Jul 24, 2006, at 6:29 PM, Steve Hannah wrote:
> Do:
> error_reporting(E_ALL);
>
> at the beginning of your script. This will display most errors.
>
> Best regards
>
> Steve
>
>
> ----------------------------------------
> Steve Hannah
> Web Services Developer
>
> Faculty of Applied Sciences
> Simon Fraser University
> shannah at sfu.ca
> 604-268-7228
> Homepage: http://www.sjhannah.com
> --
> Need to build a database driven web application quickly?
> Try Dataface: http://fas.sfu.ca/dataface
>
>
>>
>> Thanks vey much,
>> -Joel
>>
>>
>> On Jul 24, 2006, at 5:15 PM, Chris Hansen wrote:
>>
>>> Joel,
>>>
>>> First off, this is a perfectly acceptable forum for PHP questions
>>> (after all, we are all PHP users =)
>>>
>>> Here's my personal preference for checking a variable:
>>>
>>> if (isset($var) && strlen(trim($var)) > 0)
>>> {
>>> # code...
>>> }
>>>
>>> First off, I want to be sure that the variable is even set (if
>>> not, there could be an error, someone could be attempting to
>>> access something the shouldn't, etc.) Besides which, PHP will
>>> return a low level error (notice, I believe) if you otherwise
>>> check a variable that isn't set.
>>>
>>> The second check ensures that my variable not only contains data,
>>> but that the data is not merely a space. (Of course, if you want
>>> to allow data that is just spaces, or other padding characters,
>>> you'll need to modify this.)
>>>
>>> HTH
>>>
>>> --Chris Hansen
>>> FileMaker 7 Certified Developer
>>> Creator of FX.php
>>> "The best way from FileMaker to the Web."
>>> www.iViking.org
>>>
>>>
>>> On Jul 24, 2006, at 5:55 PM, Joel Shapiro wrote:
>>>
>>>> Hi all
>>>>
>>>> General PHP question here. Apologies if I shouldn't post non-FX
>>>> questions.
>>>>
>>>> When checking if a variable is not empty, are there reasons to
>>>> choose one of these over the other? (or are there preferable
>>>> options still?)
>>>>
>>>> if ( $var != '' )
>>>> {
>>>> # code...
>>>> }
>>>>
>>>>
>>>> if ( !empty($var) )
>>>> {
>>>> # code...
>>>> }
>>>>
>>>> note: it seems that isset($var) will not give me what I want,
>>>> since it can return true even if $var is set to empty
>>>>
>>>> TIA,
>>>> -Joel
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>>
>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list