PHP 4 functions to output content to the browser summary, PHP browser output function _php tutorial

Source: Internet
Author: User

PHP 4 functions to output content to the browser summary, PHP browser output function


Copy the Code code as follows:



<?php
/*
* 0x01:print () statement
* int print (arguments);
The * print () statement outputs the data passed in to the browser
*/
Print ("

I Love PHP!!!

");
Print "

I Love PHP!!!

";
?>
<?php
/*
* 0x02:echo () statement, function as function as print () function
* All data is exported to the browser
* The Echo () function performs the output slightly more efficiently than the print () function because Echo does not return the result
*/
echo "

I Love PHP!!!

";
$languge = "Java";
echo "

I Love $languge!!!

";
?>

<?php
/*
* 0X03:PRINTF () statement
* If you want to output a mixed product consisting of any static text and dynamic information stored in one or more variables, using the printf () function is ideal
The printf () function divides static data and dynamic data into two parts in the following form:
* Integer printf (string format [, mixed args]);
*/
printf ("

I Love%s!!!

"," C # ");
/*
* In the above example,%s is a placeholder, and the common placeholders are listed below
* Type description
*%b the argument as an integer, displayed as a binary number
*%c considers the argument to be an integer that is displayed as the corresponding ASCII character
*%d considers the argument to be an integer, displayed as a signed decimal number
*%f the parameter as a floating-point number, displayed as a floating-point number
*%o The argument is considered an integer, which is displayed as an octal number
*%s considers the argument to be a string and is displayed as a string
*%u considers the parameter to be an integer, which is displayed as an unsigned integer
*%x considers the argument to be an integer, which is shown as a lowercase 16 binary number
*%x considers the argument to be an integer, which is shown as an uppercase 16 binary number
*/
$num = 1024;
printf ("

%b:%c:%d:%f:%o:%s:%u:%x:%x

", $num, $num, $num, $num, $num, $num, $num, $num, $num);
?>
<?php
/*
* 0X04:SPRINTF () statement
* the sprintf () function is the same as the function of the printf function, but it is to assign the output value to a string instead of outputting it directly to the browser
* This function is useful, such as formatting a string containing dynamic output, combined with the above placeholder, can also be converted into a system, in the form of:
* String sprintf (string format [, mixed args]);
*/
$cost =sprintf ("$%.2f", 43.2);//$cost =$43.20
?>


http://www.bkjia.com/PHPjc/912670.html www.bkjia.com true http://www.bkjia.com/PHPjc/912670.html techarticle PHP to the browser output content of 4 function summary, PHP browser output function copy code as follows:! DOCTYPE unspecified public "-//w3c//dtd HTML 4.01 transitional//en" "Http://ww ...

  • Related Article

    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.