Re: warning message to hide

From: Date: Thu, 19 Apr 2007 04:01:58 +0000
Subject: Re: warning message to hide
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-253237@lists.php.net to get a copy of this message
On Wed, April 18, 2007 1:55 am, Tijnema ! wrote: >> @$conn = pg_connect($conn_string); > > Ok, you're right, both are valid. But i think it's better to use it > before the function name. (like all examples in the manual do ). > > Else you might end up with code like this: > my_function(@$var); > > Which will result in a parse error... What makes you think that will result in a parse error?... :-) $var is an expression @$var will suppress any error messages of that expression So I'm pretty sure that not only will that not result in a parse error, it's a Documented Feature. For example, if you have E_NOTICE on, and you didn't want to actaully FIX your code correctly, the @ would suppress the E_NOTICE from this (complete) script: <?php function my_function identity($foo){ return $foo; } my_function($bar); //E_NOTICE is output my_function(@$baz); //no E_NOTICE ?> At least, that's what *I* would expect to happen, and it did in my quickie CLI test I just ran, I think... Not sure I even had E_NOTICE cranked up in CLI, but it sure wasn't a parse error. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#253237) next »