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 ! 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