
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP Error Control Operator
Introduction
In PHP @ symbol is defined as Error Control Operator. When it is prefixed to any expression, any error encountered by PHP parser while executing it will be suppressed and the expression will be ignored.
Following code tries to open a non-existing file for read operation, but PHP parser reports warning
Example
<?php $fp=fopen("nosuchfile.txt","r"); echo "Hello World
"; ?>
Output
Following result will be displayed
Hello World PHP Warning: fopen(nosuchfile.txt): failed to open stream: No such file or directory in /home/cg/root/1569997/main.php on line 2
Prepending @ symbol to fopen() expression suppresses error message and statement itself is ignored
Example
<?php $fp=@fopen("nosuchfile.txt","r"); echo "Hello World"; ?>
Output
Following result will be displayed
Hello World
Advertisements