Log in

View Full Version : What does '@' do in front of a variable?



eke
05-05-2006, 08:05 AM
Hi All,

My first time posting on any php forum but i've searched all over (maybe not using the right search terms).

I'm trying to debug a script and ran into a variable assignment i hadn't seen before - @$$value.

I know $$ means value is a variable variable. I also know '@' suppresses error messages in functions but i can't figure out what the combination actually does.

The script actually still works without the '@' but i'm curious.

Thanks in advance.

djr33
05-05-2006, 08:14 AM
As you say, it prevents error messages from being displayed.

As such, I can only assume that it doesn't give you an error if there is something wrong with "$$var".

Perhaps it's used in case "$var" has no value, in which case, it would give you an error because you're trying to assign a value to "$" ($blank).

eke
05-05-2006, 09:02 AM
Thanks a lot. Didn't think of that. I'll have a go at introducing errors to see what happens with and without the '@'.

djr33
05-05-2006, 10:22 AM
Yeah. That's a good way to test.
I've only seen the @ used on functions, but I would assume other things would work in a similar fashion.

Twey
05-05-2006, 10:40 AM
I would think that was it. I've never seen this before either. I'd like to have a look at this code: it's either very badly written, or very well written.

Lol, @$$value.

djr33
05-05-2006, 10:41 AM
it's either very badly written, or very well written.:D
So true. Ha.

Well, really, that's just intermediate. The users who are using @$$$$value are the ones who really get it. ^_^

:p