php先把数据返回浏览器,PHP向浏览器输出数据的命令

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:29   1571   0

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的差异在于此函数只返回结果,不直接输出到浏览器。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP