PHP print



PHP Tutorial > String Functions > print

In PHP, print is used to output one or more strings. Even though print behaves like a string function, it is technically not a function, as it doesn't require a parenthesis in its function.

print and echo are very similar in PHP. The one difference is that echo can be used to concatenate string, while print cannot do so.

The syntax of the print construct is:

print 'string'

Let's take a look at the examples below:

Example 1

print 'You are reading a tutorial on PHP print construct.';

Result:

You are reading a tutorial on PHP print construct.

Example 2

$var = 'Learn PHP print';
print $var;

Result:

Learn PHP print

Next: PHP str_replace Function



Copyright © 2023   1keydata.com  All Rights Reserved.  Privacy Policy   About   Contact