PHP ctype Functions | ctype Functions In PHP In Hindi
PHP Security Tips : Hiding php In URL (In Hindi)
PHP com port communication In Hindi | Write on com port in PHP
PHP Form validation | Validate User Input Data In PHP In Hindi
PHP object Type Casting In Hindi | PHP object In Hindi
Best Keyboards Under 1000 Available On Amazon
Time Travel In Snowflake In Hindi | Snowflake Time Travel Example
what is switch ? And How switch works ?
Laravel Generate PDF Example | Download And Generate PDF In Laravel In Hindi
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 में Null Coalescing Operator सिर्फ ternary operator की जगह use किया जाने वाला operator था। जिसका main purpose isset() और ternary operator को replace की तरह use में लिया गया। इस Operator को PHP version 7
में introduce किया था।
Null coalescing operator , दो operands के साथ work करता है अगर first operand की value null
, empty और undefined
नहीं हुआ तो first operand return करेगा otherwise second operand return होगा।
<?php
// here $var is not defined.
echo $var ?? "Variable not defined";
?>
इसी तरह से अगर variable की value null
या 0 हुई तो second operand return होगा।
<?php
$var = null;
echo $var ?? "null Variable";
echo "<br/>"; // line break.
// now put some value.
$var = "Hello ! learners.";
echo $var ?? "null Variable";
?>
Null coalescing operator काफी easy to use है और ternary या if-else के comparison में काफी short भी है। इसे आप one line code वाली condition की जगह आसानी से use कर सकते हैं।
अब आप PHP में Null coalescing operator के बारे अच्छे से समझ गए होंगे।
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