Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
RE: [PHP] Problem with MySQL
Old
  (#1)
Richard Lynch
Guest
 
Posts: n/a
Default RE: [PHP] Problem with MySQL - 05-14-2007, 03:55 AM

On Tue, March 20, 2007 11:08 am, Ford, Mike wrote:
>> what do you want with that '@' here?
>> that operator can be used to suppress error messages when calling
>> functions but not when using a variable


This is most definitely way wrong.

> What complete tosh! @ is a unary operator, so can be applied to any
> expression.
>
> Proof:
>
> <?php
> echo "no @ --", $HTTP_GET_VARS['bogus'], "<br />\n";
> echo "with @ --", @$HTTP_GET_VARS['bogus'], "<br />\n";
> ?>
>
> Result:
>
> no @ --
> Warning: Undefined index: bogus in
> c:\www-lco\scripts_etc\lco\php\test.php on line 18
>
> with @ --
>
>
> Also:
>
> <?php
> $a = 123;
> echo "no @ --", $a/0, "<br />\n";
> echo "with @ --", @($a/0), "<br />\n";
> ?>
>
> Result:
>
> no @ --
> Warning: Division by zero in c:\www-lco\scripts_etc\lco\php\test.php
> on line 19
>
> with @ --
>
>
> Not that I'm necessarily advocating this as a technique, but let's not
> spread disinformation!


While it has now been proven that @ is "more" than a function
error-suppressant, I suspect it may technically be a Language
Construct rather than a simple unary operator...

Not that I can come up with anything yet to prove it, as all my
examples so far were total syntax errors...

Although I did find an interesting anomoly...

What would you expect this to output?
<?php @ ?>

Hint:
I figured it would apply the @ to no expression at all and do nothing.
I was wrong.

I suppose I could try to read PHP source and figure all this out
someday...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top