PHP Program to check whether number is Palindrome or not | PHP Find Palindrome Number
PHP null In Hindi | PHP is null Function
Bubble Sort in PHP With Example | How Bubble Sort Works in PHP
PHP var_export() Function In Hindi | var_export() In PHP In Hindi
PHP object Type Casting In Hindi | PHP object In Hindi
How to setup MongoDB In Laravel : Laravel with MongoDB
Difference between Analog and Digital signal In Hindi
Set In JavaScript In Hindi | JavaScript Set
Java program to check if string is a palindrome : check palindrome string in java
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.
Error Control In PHP
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 ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook