PHP var_export() Function In Hindi | var_export() In PHP In Hindi
PHP null In Hindi | PHP is null Function
PHP Interview Questions In Hindi : PHP Interview Preparation
Insertion Sort in PHP With Example | How Does Insertion Sort Work in PHP
AWS Storage Service In Hindi : Types of AWS Storage Services
Linux rm Command Example | Remove file / directory In Linux
How to Implement RESTful APIs In NodeJS In Hindi | NodeJS RestFul API Example
Linux adduser Command In Hindi
C program to check if a number is Armstrong : Find Armstrong Number In C
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
PHP एक error control operator - at sign (@)
को भी support करती है , इसे sign को किसी expression से पहले prepend किया जाता है, और अगर उस expression में कोई diagnostic error generate हुई तो suppress / ignore हो जाएगी।
For Example
<?php
$x = $arr[0];
// Error : PHP Warning: Trying to access array offset on value of type null.
?>
ऊपर दिए गए example में अगर , कोई Array variable define नहीं है still उसे access करने का try किया तो कुछ इस तरह से error आयी। इससे बचने के लिए आप simply @
prepend कर सकते हैं।
जैसे
<?php
$x = @$arr[0];
?>
अब error तो control हो गयी , लेकिन अब अगर आपको error message पता करना है तो आप error_get_last()
function को call कर सकते हैं जो last error के बारे men एक Associative Array return करता है।
<?php
$x = @$arr[0];
print_r(error_get_last());
?>
Output
Array ( [type] => 2 [message] => Trying to access array offset on value of type null [file] => C:\Users\verma\Desktop\test.php [line] => 2 )
अब इस array से message key को आप easily access करके error message print करा सकते हैं।
Internally @
operator , उस particular line के लिए error reporting level 0
set करता है , जिससे सिर्फ warning और parse error ही ignore होती हैं। हालाँकि Fatal Error को इससे नहीं रोका जा सकता है।
जैसे कि नीचे दिए गए example में undefined function test()
को call किया गया।
<?php
$x = @test();
// Fatal error: Uncaught Error: Call to undefined function test()
?>
जहाँ तक हो सके Error Control Operator @ का use कम ही करें , इससे execution और performance slow होता है , हालाँकि आप need के according variables को एक default value set कर सकते हैं।
Loading ...
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook