PHP null In Hindi | PHP is null Function

Blogs ❯❯ PHP

Image could not load

PHP null In Hindi

null In PHP In Hindi

PHP में null type एक unit type जिसमे सिर्फ एक ही value है - null . यह case-insensitive constant value है मतलब इसे आप Null / NULL कैसे भी लिख सकते हैं लेकिन इसे change नहीं कर सकते।

<?php $x = NULL; ?>

PHP null Example

आप null variable को किसी numeric value से calculation भी कर सकते हैं लेकिन ध्यान रहे इस case में null 0 की तरह work करेगा।

<?php $num = null; $num += 10; echo "{$num} \n"; $num -= 2; echo "{$num} \n"; $num *= 2; echo "{$num} \n"; ?>

Output :

10 
8 
16

Important* null values पर increment और decrement operator work नहीं करेंगे।

<?php $num = null; ++$num; // null $num++; // null $num--; // null --$num; // null ?>

Array comparison with null

किसी empty Array को आप null से compare भी कर सकते हैं , लेकिन ध्यान रहे non-strict equal (==) के साथ compare करने पर आपको true मिलेगा जबकि strict equal (===) compare करने पर false .

For Example

<?php $arr = []; echo $arr == null ? "true" : "false"; echo "\n"; echo $arr === null ? "true" : "false"; ?>

Output :

true
false

PHP is_null Function

कोई variable null है या नहीं ये check करने के लिए is_null() function का use किया जाता है।

<?php $x = null; echo is_null($x) ? "true" : "false"; ?>

Output :

true

I Hope, अब आप PHP men null के behavior के बारे में अच्छे से समझ गए होंगे।

Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

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