Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

@$ in PHP

Posted on 2013-12-27
6
Medium Priority
?
186 Views
Last Modified: 2013-12-29
hi

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

example:   @$variableTest
0
Comment
Question by:joyacv2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 84

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 111

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 111

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

704 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