PHP

PHP Echo / Print

Simply, the echo statement is used to output data. In most cases, anything output by echo ends up viewable in the browser. You could also have used the print()  function in place of the echo statement. Using echo or print() is a  matter of taste; when you look at other people’s scripts, you might see either use.
Whereas echo is a statement, print() is a function. A function is a command thatperforms an action, usually modified in some way by data provided for it. Data sent to a function is almost always placed in parentheses after the function
name. In this case, you could have sent the print() function a collection of characters, or a string. Strings must always be enclosed in quotation marks, either single or double. For example:

<?php
print(“Hello Web!”);
?>

Difference Between Echo and Print

ECHOPRINT
Parametersecho can take more than one parameter when used without parentheses. The syntax is echo expression [ expression[expression] … ]. Note that echo ($arg1 comma $arg2) is invalid.print only takes one parameter.
Return valueecho does not return any valueprint always returns 1 (integer)
Syntaxvoid echo (string $arg1[string $… ] )int print (string $arg)
What is it?In PHP echo is not a function but a language construct.In PHP print is not a really function but a language construct. However it behaves like a function in that it returns a value.

Recommended Tutorials for you


Related posts

Time Ago Script

Anuj Kumar

PHP Intro

Anuj Kumar

Adding Comments to PHP Code

Anuj Kumar

Understanding of php.ini

Anuj Kumar

How to upload and validate a image in php

Anuj Kumar

Types of Errors in PHP

Anuj Kumar

Conditional Statement

Anuj Kumar

PHP Variables

Anuj Kumar

Captcha Image Verification

Anuj Kumar

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.