- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of the @ symbol in PHP?
PHP supports the error control operator i.e. the at sign (@). When @ is prepended to an expression, any error messages that might be generated by that expression gets ignored.
To use @ symbol in PHP, the code is as follows−
Example
<?php $file = @file ('non_existent_file') or die ("Failed in opening the file: Error Message = '$err'"); $value = @$cache[$key]; ?>
Output
This will produce the following output−
Failed in opening the file: Error Message = ''PHP Notice: Undefined variable: err in /home/cg/root/6985034/main.php on line 4
Example
Let us now see another example−
<?php $val = $test['5'] $val = @$test['5'] ?>
Output
This will produce the following output−
PHP Parse error: syntax error, unexpected '$val' (T_VARIABLE) in /home/cg/root/6985034/main.php on line 5
Advertisements