Solved

@$ in PHP

Posted on 2013-12-27
6
179 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 110

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 110

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 110

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

636 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