Solved

@$ in PHP

Posted on 2013-12-27
6
171 Views
Last Modified: 2013-12-29
hi

what is a @ symbol before a $ in a variable declaration

example:   @$variableTest
0
Comment
Question by:joyacv2
6 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39742993
Suppress any error
http://php.net/manual/en/language.operators.errorcontrol.php

In that case if the var doesn't exist then the code won't burp
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39742998
It's almost certainly a mistake!  The correct approach is to avoid error suppression, and instead fix the underlying condition that could raise a message.

Think about this for a moment.  What if you used error suppression on a function call that created a Fatal error?  Your script would fail with a run-time error, possibly after damaging some of your data model, and you would have no way of knowing why the error occurred or where the script was in the progress of completing its task.

This by itself is meaningless: @$variableTest.  The @ suppresses messages and the simple statement of a variable name cannot issue a message.  More often we see it used in something like this:

$fp = @fopen(...)

In that context, the message about "file not found" can be suppressed.  Other parts of the PHP script will need to deal with the missing file.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39743029
I agree with Ray.  I don't think I have Any code that uses a '@' to suppress error reporting... because it does not suppress the error, it just fails to 'report' it.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39743051
Very well put, Dave.  It's like you still ran over the cat, you just didn't tell anyone.  No problem till someone says, "Here kitty" or notices that the mice are eating all of the cheese.
0
 
LVL 20

Expert Comment

by:Mark Brady
ID: 39743577
@Ray ..
No problem till someone says, "Here kitty" or notices that the mice are eating all of the cheese.

Hahahaha nice!
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39744708
Thanks for the points and thanks for using EE.  Going forward, don't feel uncomfortable about sharing the points among the answers that contribute to your understanding.  Both Gary and Dave added good information here, too!

Best wishes for new year 2014, ~Ray
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question