PHP print output string

 PHP print can be used to output PHP strings. The usage is similar to echo . Strictly speaking, PHP print itself is not a PHP function, and its execution efficiency is slightly slower than echo . When the processing program is simple, the difference between the two is actually not big, PHP print output can use single quotes simple string, you can also use double quotes output variable value.


PHP print basic syntax

print( $string ); or print $string;


Because print is not a function, it is not necessary to wrap the variables in parentheses . Instead, you can directly output the variables , and you can output a single variable or a combination of multiple sets of variables at a time, only through single quotes (''), Double quotation marks ("") or string concatenation (.) can change many different results.

PHP print example
<?php
$NewString1 ='Welcome to Wibibi.';
$NewString2 ='Have a good day.';
print($NewString1).$NewString2.'<br>';
echo $NewString1.$NewString2;
?>
The output of the above example
Welcome to Wibibi.Have a good day.
Welcome to Wibibi.Have a good day.
We compared the results of print and echo in the example . In fact, the results of both are the same. In fact, whether it is echo or print, you can use parentheses to enclose variables , but usually it is not necessarily used in this way. After all, both These are not functions, and direct output is more intuitive. In addition, the example also uses the string connection symbol "." to concatenate variables together, and even add HTML symbols, which are commonly used string output tips.

Post a Comment

0 Comments