Solved

@$ in PHP

Posted on 2013-12-27
6
173 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
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…

710 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