Php Echo And Print Function

In this PHP tutorial, We are going to learn PHP echo print function that how we can print anything using this two PHP function.In HTML whatever we write it will display on the webpage. But tags are not visible.But in PHP we need to write everything inside a PHP script.

But the code that we write inside the script is not visible until we use a PHP function to make it visible. So there is two function are used to print the PHP values.

 PHP Echo Print Function

php echo print function

  1. ECHO FUNCTION
  2. PRINT FUNCTION 

PRINT FUNCTION

  • PHP PRINT function is used to display output.
  • PHP PRINT function can be used to print one or more string.
  • PHP PRINT function can be used with parentheses or without parentheses.
  • PHP PRINT function is slower than the echo function.
  • PHP PRINT function always has a return value which is 1.

In above example,  $name behaves as a string because it’s holding a character on double quotes. Then we are using print function two ways to represent the result. Either you can use the PHP PRINT function with parentheses or without parentheses result is same.

Result: my name

PHP ECHO FUNCTION

  • PHP ECHO function is also used for display output.
  • PHP ECHO function is faster than PHP PRINT function.
  • PHP ECHO function can be used with parentheses or without parentheses.
  • PHP ECHO function does not have a return value.

In above example,  $name behaves as a string because it’s holding a character on double quotes. Then we are using print function two ways to represent the result. Either you can use the PHP ECHO function with parentheses or without parentheses result is same.

Result: my name

Conclusion

Here we can see that PHP PRINT function and PHP ECHO function both can be used to display output at the client side.If you have any query related to  PHP echo print function post feel free to comment on the comment box.Do not forget to share this post because someone else also needs this. And don’t forget to like on Facebook Page.

Also Read:

  1.  PHP Tutorial – PHP Introduction
  2.  Explode And Implode Function In Php

Leave a Reply

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