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.
unset() , किसी variable को unset करता है। unset करने का मतलब है उस variable को NULL assign करता है , जिससे उस variable की value को आगे use न कर सकें।
PHP unset() Syntaxunset ( mixed $var , mixed ...$vars );
mixed $var | required : variable जिसे आपको unset करना है।
mixed ...$vars | optional : आप एक साथ कई variables unset कर सकते हैं। हालाँकि कम से काम एक variable mandatory होता है।
Return Value : variable unset होने के बाद true return करता है , otherwise false .
mixed type का मतलब होता है , कि आप अपनी need के according किसी भी type (String , Boolean , Array , Class , Numeric) की value pass कर सकते हैं। यह जरूरी नहीं है कि कोई special type की value ही pass करें।
File : php_unset.php
<?php
$var = "Hello world!.";
unset($var);
var_dump($var);
?>
NULL
हालाँकि unset() का use करके आप normal variable के अलावा Array / Object / Session भी unset कर सकते हैं।
$arr = ['red' => 'aaple', 'yellow' => 'Banana', 'Green' => 'Guava']; print_r($arr); echo "After unset 'red' "; unset($arr['red']); print_r($arr);Output :
Array ( [red] => aaple [yellow] => Banana [Green] => Guava ) After unset 'red' Array ( [yellow] => Banana [Green] => Guava )
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