欢迎来到天天文库
浏览记录
ID:41395065
大小:64.67 KB
页数:11页
时间:2019-08-24
《PHP打印函数集合》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、PHP打印函数集合1echo(),print();3(4);printf():5sprintf():printr(6);vardump(7);1echo()可以同时输出多个字符串,可以多个参数,并不需要圆括号,无返回值.2print()只可以同时输出一个字符串,一个参数,需要圆括号,有返回值,当其执行失败时返flase.print的用法和c语言很像,所以会对输出内容里的%做特殊解释.the(3);有两个功能:先输出内容,然后退出程序.(常用在链接服务器,数据库)_mysqlconnect("locahost
2、",〃:root",〃root〃)ordie(〃链接服务器失败!〃);4printf();printf("参数1",参数2):参数1=按什么格式输出;参数2二输出的变量.($S:按字符申;$d:按整型;$b:按二进制;$x:按16进制;$o:按八进制;$f:按浮点型)
3、0.001—-100—-1100100—-64-—144—-1001.00100printf(〃%・2f〃,$num);//100.00(小数点保留2位)printf(〃%.If",$num);//100.0(小数点保留1位)printf(〃%〃#10s〃,$num);//###100.001printf(〃%'@10s〃,$num);//@@@100.001printf(〃%〃_10s〃,$num);//100.001printf(〃%〃#-10s〃,$num);//100.001###printf(〃%
4、〃@-10s〃,$num);//100.001@@@printf(〃%〃_-10s〃,$num);//100.001printf(〃%〃#20s〃,$num);//#############100.0014sprintf();此并不能直接输出,先赋给一个变量,然后再输出变量.5print_r()・功能:只用于输岀数组.6vardump(_);功能:输岀变量的内容,类型或字符串的内容,类型,长度•常用来
5、调试.输岀结果是hello?O
6、utput:aaalObbb"PHP?Echo(〃AAA〃,〃10〃,>?WrongoutputresultAsto.・・:・・・Print()Youcanoutputaparameterwithparenthesesandnobrackets.Youcan,toutputmultipleparameterswithreturnvalue1,0"PHP?If("print'("HelloPHP")){〃Echo〃failedtooutput";RunresultsHelloPHPAsto...:.(die)
7、DieoutputsthecontentsandexitstheprogramOutputwithbracesandonlywithoneparameter,wecanonlywritelikethis:"PHP?Die(〃###〃);>?Theoperationresults###Sprintf()Function:sprintf()--formattingstrings.Syntax:string,sprintf(string,format,mixed,[args],・・・);Returnvalue:S
8、tringThisfunctionisusedtoformatstrings・Theparameterformatistheformatoftheconversion,startingwiththepercentagesymbol%untiltheconversioncharacter.Thetypecodefortheconversionisasfollows:Bintegerconvertedtobinary
此文档下载收益归作者所有