Hi,
I'm new to PHP and using symfony for a project. I noticed the following line:
in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))
I can see what the line is doing, but I'm not sure what the @ symbol does in the syntax. I've done some searches through the PHP reference manuals and I can't seem to find any documentation about this syntax.
Can anyone explain what it does?
Thanks,
Steve
What does the @$ syntax mean?
Moderator: General Moderators
-
steve_the_canuck
- Forum Newbie
- Posts: 8
- Joined: Fri Jan 30, 2009 6:36 pm
Re: What does the @$ syntax mean?
If the array index is not defined, the error will be suppressed.
Re: What does the @$ syntax mean?
See this example,
To avoid the warning message, we are using this '@' symbol here.
Code: Select all
$checking_updateQuery = mssql_query($updateQuery);
$outResult = @mssql_fetch_array($checking_updateQuery);Re: What does the @$ syntax mean?
If this thread is going to stay alive then I might as well make this comment:
Don't rely on this thing to fix your problems. If you get a warning message you should try to fix the code first. I know of no circumstances where a @ is necessary, and precious few where I consider it excusable. An E_NOTICE is a minor issue, an E_WARNING something you should pay attention to, and an E_ERROR as a major bug. Address as many of these as you can and there will be less bugs, and everybody can agree that fewer bugs in the code is a good thing.
If you want to hide errors on a global scale, edit your php.ini file and change display_errors to "off" or zero. This isn't a good idea for a testing environment but a must for production. Errors should then be logged somewhere (see the error_log setting) so you don't miss out on the messages.
Don't rely on this thing to fix your problems. If you get a warning message you should try to fix the code first. I know of no circumstances where a @ is necessary, and precious few where I consider it excusable. An E_NOTICE is a minor issue, an E_WARNING something you should pay attention to, and an E_ERROR as a major bug. Address as many of these as you can and there will be less bugs, and everybody can agree that fewer bugs in the code is a good thing.
If you want to hide errors on a global scale, edit your php.ini file and change display_errors to "off" or zero. This isn't a good idea for a testing environment but a must for production. Errors should then be logged somewhere (see the error_log setting) so you don't miss out on the messages.