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 में हम value को print कराने के लिए echo() function का Use करते है , echo के बाद आप Parenthesis use कर भी सकते हैं और न भी करते हैं तो भी कोई problem नहीं है।
Example -
File : test.php
<?php
$name = "Rahul Kumar";
echo $name."<br>";
echo($name);
?>
Example में आप देख सकते हैं की value को हम दोनों तरह से Print करा सकते हैं। इसके अलावा PHP में print() function भी है जिसे हम value को print करने में ले सकते है।
Note - Example में '<br>' का use line break के लिए किया गया है और dot (.) का use String Concatenation के लिए।
File : test2.php
<?php
$name = "Rahul Kumar";
print$name."<br>";
print($name);
?>
सबसे बड़ा difference यह है कि echo() function किसी value को print करने के बाद कुछ return नहीं करता जबकि print() function value को print करने के बाद 1 return करता है।
File : test3.php
<?php
$name="Rahul";
echo print($name)."<br>";
?>
Note - print() function हमेशा ही 1 return करता हो चाहे value print हो या न हो , variable Define किया गया हो या न किया गया हो|
File : test4.php
<?php
$name;
echo print($name);
echo print($nsame);
?>
ऊपर दिए गए Example में आप देख सकते हैं एक variable को सिर्फ initialize किया गया है कोई value assign नहीं की गयी जबकि दूसरी लाइन में non-define variable print कराने की कोशिश की but error आने के बाद भी print() function ने 1 return किया।
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