The difference between echo, print, printf and sprintf_PHP Tutorial

WBOY
Release: 2016-07-21 15:59:41
Original
764 people have browsed it

- echo

is a command and cannot return a value. Echo can be followed by many parameters, separated by semicolons, such as:
echo $myvar1;
echo 1,2,$myvar,"bold";

- print

is a function that can return a value and can only have one parameter.

- printf

function, format the text and then output it, such as:
$name="hunte";
$age=25;
printf("my name is %s, age %d", $name, $age);

- sprintf

is similar to printf, but does not print, but returns formatted text, others Same as printf.
- echo

is a command and cannot return a value. Echo can be followed by many parameters, separated by semicolons, such as:
echo $myvar1;
echo 1,2,$myvar,"bold";

- print

is a function that can return a value and can only have one parameter.

- printf

function, format the text and then output it, such as:
$name="hunte";
$age=25;
printf("my name is %s, age %d", $name, $age);

- sprintf

is similar to printf, but does not print, but returns formatted text, others Same as printf.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317297.htmlTechArticle-echo is a command and cannot return a value. Echo can be followed by many parameters, separated by semicolons, such as: echo$myvar1; echo1,2,$myvar,"bold"; -print is a function that can return a value,...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!