PHP outputs four functions to the browser, and the php browser outputs the functions.

Source: Internet
Author: User

PHP outputs four functions to the browser, and the php browser outputs the functions.

Copy codeThe Code is as follows:
<! DOCTYPE unspecified PUBLIC "-// W3C // dtd html 4.01 Transitional //" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Body>
<? Php
/*
* 0x01: print () Statement
* Int print (arguments );
* The print () Statement outputs the data passed in to the browser.
*/
Print ("<p> I love PHP !!! </P> ");
Print "<p> I love PHP !!! </P> ";
?>
<? Php
/*
* 0x02: echo () Statement, which has the same function as the print () function.
* All data is output to the browser.
* The output efficiency of the echo () function is slightly better than that of the print () function, because echo does not return results.
*/
Echo "<p> I love PHP !!! </P> ";
$ Required Ge = "Java ";
Echo "<p> I love $ sharege !!! </P> ";
?>

<? Php
/*
* 0x03: printf () Statement
* If you want to output a hybrid product composed of any static text and dynamic information stored in one or more variables, the printf () function is ideal.
* The printf () function divides static data and dynamic data into two parts, in the form:
* Integer printf (string format [, mixed args]);
*/
Printf ("<p> I love % s !!! </P> "," C #");
/*
* In the preceding example, % s is a placeholder. Common Placeholders are listed below.
* Type description
* % B indicates that the parameter is regarded as an integer and displayed as a binary number.
* % C considers the parameter as an integer and displays it as an ASCII character.
* % D the parameter is regarded as an integer and displayed as a signed decimal number.
* % F considers the parameter as a floating point number and displays it as a floating point number.
* % O considers the parameter as an integer and displays it as an eight-digit number.
* % S: the parameter is considered a string and displayed as a string.
* % U is regarded as an integer and displayed as an unsigned integer.
* % X indicates an integer that is regarded as a lowercase hexadecimal number.
* % X indicates an integer that is an uppercase hexadecimal number.
*/
$ Num = 1024;
Printf ("<p> % B: % c: % d: % f: % o: % s: % u: % x: % X </p> ", $ num, $ num );
?>
<? Php
/*
* 0x04: sprintf () Statement
* The sprintf () function is the same as the printf function, but it assigns the output value to a string instead of directly outputting it to the browser.
* This function is very useful. For example, you can format a string containing dynamic output and combine it with the placeholder above to perform hexadecimal conversion. The form is:
* String sprintf (string format [, mixed args]);
*/
$ Cost = sprintf ("$ %. 2f", 43.2); // $ cost = $43.20
?>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.