相思资源网 Design By www.200059.com
复制代码 代码如下:
<?php
/*************by garcon1986*********/
//print和echo的区别:
//1. echo可以输入多个字符串,而print不能。
print "hello"."world"; //成功
echo "hello"."world"; //成功
//print "hello","world"; //失败
echo "hello","world"; //成功
//2. echo比print更快。
$stime = microtime(true);
print "hello"."world";
$etime = microtime(true);
$total = $etime - $stime;
echo $total.'<br/>';
//microtime — Return current Unix timestamp with microseconds
$stime2 = microtime(true);
echo "hello"."world";
$etime2 = microtime(true);
$total2 = $etime2 - $stime2;
echo $total2.'<br/>';
//执行结果:
//helloworld0.0014331340789795
//helloworld0.00018310546875
//看到echo比print更快。
//print_r — Prints human-readable information about a variable 或数组
$a = "sajfd sfjal sfjalwureoi weu sj we fk io ";
print_r($a);
echo '<br />';
$a = array("b","c","d");
print_r($a);
echo '<br />';
//var_dump — Dumps information about a variable 或数组
//var_dump -- 打印变量的相关信息
$a = "sajfd sfjal sfjalwureoi weu sj we fk io ";
var_dump($a);
echo '<br />';
$a = array("b","c","d");
var_dump($a);
echo '<br />';
var_dump(array("b","c","d"));
echo '<br />';
?>
<?php
/************by garcon1986********/
//%% - 返回百分比符号
//%b - 二进制数
//%c - 依照 ASCII 值的字符
//%d - 带符号十进制数
//%e - 可续计数法(比如 1.5e+3)
//%f - 浮点数(local settings aware)
//%F - 浮点数(not local settings aware)
//%o - 八进制数
//%s - 字符串
//%u - 无符号十进制数
//%x - 十六进制数(小写字母)
//%X - 十六进制数(大写字母)
//printf()函数输出格式化的字符串
$str = "hello";
$number = 456;
//example1
printf("%s world. Day number %s", $str, $number); //输出: hello world. Day number 456
print "<br/>";
//example2
printf("%%", $number); //%
print "<br/>";
printf("%b", $number); //111001000
print "<br/>";
printf("%c", $number); //ascii码
print "<br/>";
printf("%d", $number); //456
print "<br/>";
printf("%e", $number); //4.560000e+2
print "<br/>";
printf("%f", $number); //456.000000
print "<br/>";
printf("%F", $number); //456.000000
print "<br/>";
printf("%o", $number); //710
print "<br/>";
printf("%s", $number); //456
print "<br/>";
printf("%u", $number); //456
print "<br/>";
printf("%x", $number); //1c8
print "<br/>";
printf("%X", $number); //1C8
print "<br/>";
printf("With 2 decimals: %1\$.2f<br />With no decimals: %1\$u<br />",$number);
//With 2 decimals: 456.00
//With no decimals: 456
printf("With 2 decimals: %f<br />With no decimals: %1\$u<br />",$number);
//With 2 decimals: 456.000000
//With no decimals: 456
//fprintf() 函数把格式化的字符串写到指定的输出流(例如:文件或数据库)。
$file = fopen("text.txt","w");
echo fprintf($file, "fprintf 1: %s world. Day number %u", $str, $number).'<br/>'; //38
echo fprintf($file, "fprintf 2: %f", $number).'<br/>'; //21
echo fprintf($file,"fprintf 3: With 2 decimals: %1\$.2f\nWith no decimals: %1\$u",$number).'<br />'; //56
//vprintf()函数输出格式化的字符串。
//vprintf() 中的 arg 参数位于数组中。数组的元素会被插入主字符串的百分比 (%) 符号处。该函数是逐步执行的。在第一个 % 符号中,插入 arg1,在第二个 % 符号处,插入 arg2,依此类推。
vprintf("vprintf: %s world. Day number %u", array($str,$number)); //vprintf: hello world. Day number 456
echo '<br />';
//sprintf() 函数把格式化的字符串写写入一个变量中。
$txt = sprintf("sprintf: %s world. Day number %u",$str,$number);
echo $txt.'<br />'; //sprintf: hello world. Day number 456
//vfprintf() Operates as fprintf() but accepts an array of arguments, rather than a variable number of arguments.
echo vfprintf($file, "vfprintf: %s world! Day number %u", array($str, $number)).'<br />'; //37
//vsprintf() Operates as sprintf() but accepts an array of arguments, rather than a variable number of arguments.
$txt = vsprintf("vsprintf: %s world. Day number %u",array($str,$number));
echo $txt.'<br />'; //vsprintf: hello world. Day number 456
?>
<?php
/*************by garcon1986*********/
//print和echo的区别:
//1. echo可以输入多个字符串,而print不能。
print "hello"."world"; //成功
echo "hello"."world"; //成功
//print "hello","world"; //失败
echo "hello","world"; //成功
//2. echo比print更快。
$stime = microtime(true);
print "hello"."world";
$etime = microtime(true);
$total = $etime - $stime;
echo $total.'<br/>';
//microtime — Return current Unix timestamp with microseconds
$stime2 = microtime(true);
echo "hello"."world";
$etime2 = microtime(true);
$total2 = $etime2 - $stime2;
echo $total2.'<br/>';
//执行结果:
//helloworld0.0014331340789795
//helloworld0.00018310546875
//看到echo比print更快。
//print_r — Prints human-readable information about a variable 或数组
$a = "sajfd sfjal sfjalwureoi weu sj we fk io ";
print_r($a);
echo '<br />';
$a = array("b","c","d");
print_r($a);
echo '<br />';
//var_dump — Dumps information about a variable 或数组
//var_dump -- 打印变量的相关信息
$a = "sajfd sfjal sfjalwureoi weu sj we fk io ";
var_dump($a);
echo '<br />';
$a = array("b","c","d");
var_dump($a);
echo '<br />';
var_dump(array("b","c","d"));
echo '<br />';
?>
<?php
/************by garcon1986********/
//%% - 返回百分比符号
//%b - 二进制数
//%c - 依照 ASCII 值的字符
//%d - 带符号十进制数
//%e - 可续计数法(比如 1.5e+3)
//%f - 浮点数(local settings aware)
//%F - 浮点数(not local settings aware)
//%o - 八进制数
//%s - 字符串
//%u - 无符号十进制数
//%x - 十六进制数(小写字母)
//%X - 十六进制数(大写字母)
//printf()函数输出格式化的字符串
$str = "hello";
$number = 456;
//example1
printf("%s world. Day number %s", $str, $number); //输出: hello world. Day number 456
print "<br/>";
//example2
printf("%%", $number); //%
print "<br/>";
printf("%b", $number); //111001000
print "<br/>";
printf("%c", $number); //ascii码
print "<br/>";
printf("%d", $number); //456
print "<br/>";
printf("%e", $number); //4.560000e+2
print "<br/>";
printf("%f", $number); //456.000000
print "<br/>";
printf("%F", $number); //456.000000
print "<br/>";
printf("%o", $number); //710
print "<br/>";
printf("%s", $number); //456
print "<br/>";
printf("%u", $number); //456
print "<br/>";
printf("%x", $number); //1c8
print "<br/>";
printf("%X", $number); //1C8
print "<br/>";
printf("With 2 decimals: %1\$.2f<br />With no decimals: %1\$u<br />",$number);
//With 2 decimals: 456.00
//With no decimals: 456
printf("With 2 decimals: %f<br />With no decimals: %1\$u<br />",$number);
//With 2 decimals: 456.000000
//With no decimals: 456
//fprintf() 函数把格式化的字符串写到指定的输出流(例如:文件或数据库)。
$file = fopen("text.txt","w");
echo fprintf($file, "fprintf 1: %s world. Day number %u", $str, $number).'<br/>'; //38
echo fprintf($file, "fprintf 2: %f", $number).'<br/>'; //21
echo fprintf($file,"fprintf 3: With 2 decimals: %1\$.2f\nWith no decimals: %1\$u",$number).'<br />'; //56
//vprintf()函数输出格式化的字符串。
//vprintf() 中的 arg 参数位于数组中。数组的元素会被插入主字符串的百分比 (%) 符号处。该函数是逐步执行的。在第一个 % 符号中,插入 arg1,在第二个 % 符号处,插入 arg2,依此类推。
vprintf("vprintf: %s world. Day number %u", array($str,$number)); //vprintf: hello world. Day number 456
echo '<br />';
//sprintf() 函数把格式化的字符串写写入一个变量中。
$txt = sprintf("sprintf: %s world. Day number %u",$str,$number);
echo $txt.'<br />'; //sprintf: hello world. Day number 456
//vfprintf() Operates as fprintf() but accepts an array of arguments, rather than a variable number of arguments.
echo vfprintf($file, "vfprintf: %s world! Day number %u", array($str, $number)).'<br />'; //37
//vsprintf() Operates as sprintf() but accepts an array of arguments, rather than a variable number of arguments.
$txt = vsprintf("vsprintf: %s world. Day number %u",array($str,$number));
echo $txt.'<br />'; //vsprintf: hello world. Day number 456
?>
标签:
PHP,print
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无PHP print类函数使用总结的评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。