[FX.php List] else

Steve Hannah shannah at sfu.ca
Thu Jun 15 16:54:49 MDT 2006


On 15-Jun-06, at 3:49 PM, Kevin Futter wrote:

> On 15/6/06 9:23 PM, "Steve Winter" <steve at bluecrocodile.co.nz> wrote:
>
>> Jonathan,
>>
>> The first thing that strikes me is in the line;
>> if ($_POST[phone1] == "") {
>> You're missing the quotes from the parameter name, it needs to be;
>> if ($_POST['phone1'] == "") {
>
> Actually, the quotes are optional in this case - PHP will parse the
> variables out quite fine without them. However, it *is* good form  
> to use the
> quotes, since this allows you to be consistent across the board,  
> which is
> always a good thing.

I used to think this (that the quotes are optional), but this is more  
than a case of good form.  If you leave the quotes off and check your  
error log, you'll notice that it is getting filled up with warnings  
and notices about the missing quotes.  It is also quite unsafe to do  
this as, if the quotes are missing, it will first see if there is a  
constant by that name - and use the value of the constant instead of  
the literal itself.  In addition, I have run into a few cases where  
upgrading to PHP 5 broke code where quotes were missing because  
previously unreserved words became reserved.

Hence, the quotes are not optional.

Best regards

Steve Hannah


>
> -- 
> Kevin Futter
> Webmaster, St. Bernard's College
> http://www.sbc.melb.catholic.edu.au/
>
>
>
> ------------------------------------------
> This e-mail and any attachments may be confidential.  You must not  
> disclose or use the information in this e-mail if you are not the  
> intended recipient.  If you have received this e-mail in error,  
> please notify us immediately and delete the e-mail and all copies.   
> The College does not guarantee that this e-mail is virus or error  
> free.  The attached files are provided and may only be used on the  
> basis that the user assumes all responsibility for any loss, damage  
> or consequence resulting directly or indirectly from the use of the  
> attached files, whether caused by the negligence of the sender or  
> not.  The content and opinions in this e-mail are not necessarily  
> those of the College.
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>

----------------------------------------
Steve Hannah
Web Services Developer

Faculty of Applied Sciences
Simon Fraser University
shannah at sfu.ca
604-268-7228
Homepage: http://www.sjhannah.com





More information about the FX.php_List mailing list