Forum Moderators: coopster

Message Too Old, No Replies

Quick question about "@" before functions

         

Sekka

1:10 pm on Jun 1, 2006 (gmt 0)

10+ Year Member



What is the significance of "@" before a function? What does it do?

Thank you.

dreamcatcher

3:12 pm on Jun 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Sekka,

Its an error suppression symbol. You can see a little more info on it here:

[uk.php.net...]

Its not good coding practice to use it.

dc

hughie

3:35 pm on Jun 1, 2006 (gmt 0)

10+ Year Member



i find it useful when dealing with arrays that might or might not be an array at the time.

I sometimes use

if (@in_array($needle,$haystackArray))
{

}

rather than
if (is_array($haystackArray))
{
if (in_array($needle,$haystackArray))
{
//
}
}

is that bad form?

coopster

4:29 pm on Jun 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member




Its not good coding practice to use it.

I think what dc really meant to say is that it does indeed have it's purposes and times of use, but DO NOT use it to substitute for taking care of error messages that should be dealt with prior to allowing code to go out to production.

dreamcatcher

6:15 pm on Jun 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Coop, that is indeed what I meant. :)

Sekka

8:24 am on Jun 5, 2006 (gmt 0)

10+ Year Member



Ahhhhh, so that's what it does.

Well, as a rule I never use error surpression, I try and deal with them before they arise.

Thank you for the help!

eelixduppy

10:46 am on Jun 5, 2006 (gmt 0)



>>>as a rule I never use error surpression

After the development stage, it is a good idea to suppress errors just in case one arises, valuable information won't be displayed to the browser. This can be done simply by adding error_reporting(0); to the top of the script.

jatar_k

10:26 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



for a production site you should just have display_errors off and send them to a log instead

error_reporting(0) means if something is going on you won't know ;)

eelixduppy

10:30 pm on Jun 5, 2006 (gmt 0)



That makes sense; Sorry about that. Thanks Jatar.

jatar_k

11:00 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well, the thing is anyone on shared hosting may not have access to php.ini so your solution is right for that

no need to apologize ;)