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.
isset() function check करता है कि कोई variable declare किया गया है और null नहीं है। variable declare और null न होने true return करता है otherwise false.
अगर किसी variable को unset() function का use करके unset कर दिया गया है तो वह variable null समझा जायेगा ।
❕ Important
हालाँकि इस function के लिए variable को सिर्फ define करना काफी नहीं है , define किये जाने वाले variable को null छोड़कर कोई भी value assign होनी चाहिए फिर वो isset()empty string ही क्यों न हो।
isset ( mixed $var , mixed ...$vars )
mixed $value | required : value जिसे आपको check करना है। आप किसी भी type की value pass कर सकते हैं।
mixed ...$vars | optional : आप एक साथ कई variables check कर सकते हैं। हालाँकि कम से काम एक variable mandatory होता है।
Return Value : अगर value set है , तो true return होता है और बाकी conditions में false return होता है।
mixed type का मतलब होता है , कि आप अपनी need के according किसी भी type (String , Boolean , Array , Class , Numeric) की value pass कर सकते हैं। यह जरूरी नहीं है कि कोई special type की value ही pass करें।
File : php_isset.php
<?php
echo isset($name) ? '$name is set' : '$name is not set';
echo "<br>";
$a;
echo isset($a) ? '$a is set' : '$a is not set';
echo "<br>";
$b = '';
echo isset($b) ? '$b is set' : '$b is not set';
echo "<br>";
$c = false;
echo isset($c) ? '$c is set' : '$c is not set';
echo "<br>";
/*Now check all variables together*/
echo isset($a, $b, $c) ? '$a, $b, $c is set' : '$a, $b, $c is not set';
?>
$name is not set $a is not set $b is set $c is set $a, $b, $c is not set
अगर आप कई variables को एक साथ check करते हैं तो , सभी variables set होने पर true return होता है , एक भी variable set नहीं हुआ तो false return होगा। इन variables का evaluation left से right की तरफ होता है , जैसे ही कोई unset variable आता है वही से evaluation stop हो जाता है।
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