PHP向浏览器输出数据的命令: 1、print() 定义:int print(argument) 例如:<?php print("welcome"); ?> 2、echo() 定义:void echo(string argument1 [, ... string argument]) 例如:<?php echo("welcome"); ?> 3、printf() 定义:integer printf(string format [, mixed args]) 例如:<?php printf("There are %d bottles of water.", 100); ?> 显示:There are 100 bottles of water. 说明:%d是一个占位符,表示此处将显示一个值,具体值类型由%后的字母来决定,详见下面。 %b 二进制数 %c ASCII字符 %d 十六进制数 %f 浮点数 %o 八进制数 %s 字符串 %u 无符号十进制数 %x 小写十六进制数 %X 大写十六进制数 注:%.2f 表示2位小数的浮点数 4、sprintf() 定义:string sprintf(string format [, mixed arguments]) 例如:<?php $cost = sprintf("There are %d bottles of water.", 100); ?> 说明:功能和printf的差异在于此函数只返回结果,不直接输出到浏览器。
php先把数据返回浏览器,PHP向浏览器输出数据的命令
最新推荐文章于 2021-07-30 10:23:57 发布