RE: [PHP] Problem with MySQL
| From: | Németh Zoltán | Date: | Wed, 21 Mar 2007 09:58:20 +0000 |
| Subject: | RE: [PHP] Problem with MySQL | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250996@lists.php.net to get a copy of this message | ||
2007. 03. 21, szerda keltezéssel 00.04-kor Richard Lynch ezt írta:
> 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...
actually I tried it and the output suprised me also
it was
Parse error: syntax error, unexpected ';'
in /var/www/tests/kukactest1.php on line 1
although I tried it with the unary operator !
<?php ! ?>
that produces the same output
so this behaviour is probably the way operators behave...
but it is really interesting ;)
greets
Zoltán Németh
>