PHP Professional এবং Zend Certified PHP Engineer (ZCPE ) Course এ সীমিত সংখ্যক আসন বাকি আছে। আগ্রহীদেরকে অতিসত্বর মাসুদ আলম স্যার এর সাথে যোগাযোগ করার জন্য অনুরোধ করা যাচ্ছে। স্যার এর মোবাইল নম্বর : ০১৭২২ ৮১ ৭৫ ৯১

PHP Basic Part-2: PHP echo VS print statement

PHP echo VS print statement

echo vs print

If you want to show any results from the server in PHP, you need to use either echo or print. These two are languages ​​Construct in PHP . Language Construct are faster than the function. Because language Construct can show results without compiling, on the other hand, the functions can show results after compiling. And because of those languages ​​Constructs can write parenthesis “i.e ()”   with or without parenthesis.

echo "Hello world";
echo ("Hello World");
print "Hello World";
print ("Hello World");

Following all ways are correct:

Language Constructs are called basic components of any language.

We will show you deference between Echo And Print with example :

1. You can take multi parameters in echo if you are not used parenthesis. On the other hand, you can use only single parameter in print , whether it is with parenthesis or without parenthesis. Notice the following examples:

echo "1"; //valid
echo "1","2"; //valid
echo ("1","2"); //Invalid
print "1";  //valid
print ("2"); //Valid
print "1","2";  //Invalid
print ("1","2"); //Invalid

The above line 2, 3, 5, 6 is correct.   The rest will show wrong.

2. echo has no return value.   On the other hand print boolean true means, it will return 1. Seeing the example below will clear the rest:

echo print (5); // Output 51

Here we get 5 as the result of print. Then return result of print 1 we get through echo. For which we get 51 together here as a result.

Hi, My name is Masud Alam, love to work with Open Source Technologies, living in Dhaka, Bangladesh. I’m a Certified Engineer on ZEND PHP 5.3, I served my first five years a number of leadership positions at Winux Soft Ltd, SSL Wireless Ltd, Canadian International Development Agency (CIDA), World Vision, Care Bangladesh, Helen Keller, US AID and MAX Group where I worked on ERP software and web development., but now i’m a founder and CEO of TechBeeo Software Company Ltd. I’m also a Course Instructor of ZCPE PHP 7 Certification and professional web development course at w3programmers Training Institute – a leading Training Institute in the country.

One comment on “PHP Basic Part-2: PHP echo VS print statement

Leave a Reply

Your email address will not be published. Required fields are marked *

No announcement available or all announcement expired.