Re: warning message to hide

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux