Skip to Content
PHP编程:第4版
book

PHP编程:第4版

by Kevin Tatroe, Peter MacIntyre
January 2021
Intermediate to advanced
505 pages
9h 45m
Chinese
Publishing House of Electronics Industry
Content preview from PHP编程:第4版
输出字符串
85
可以用逗号分隔来指定打印多项
echo "First", "second", "third";
Firstsecondthird
在尝试
echo
多个值的时候,使用小括号会产生语法错误
//
这是一个错误的语法
echo("Hello", "world");
因为
echo
不是真正的函数,所以不能把它作为表达式的一部分使用
//
解析错误
if (echo("test")) {
echo("It worked!");
}
利用
print()
printf()
函数,可很容易纠正这种错误。
print()
print()
函数将一个值(它的参数)发送到浏览器。
if (print("test\n")) {
print("It worked!");
}
test
It worked!
printf()
printf()
函数通过替换模板(即
格式字符串
)中的值所生成的字符串进行输出。它源自
标准
C
库中的同名函数
printf()
printf()
的第一个参数是格式字符串,剩下的参数
是要替换进来的值。格式字符串中的每个
%
字符指定一个替换。
格式修饰符
在模板中,每个替换标记由一个百分号(
%
)开始,后面可能跟着一个下面列出的修饰符,
并以类型说明符结尾(在输出的时候使用
%%
得到一个百分号),修饰符必须按下面列
出的顺序出现。
1
填充符。说明该字符用于填充结果,使结果为适当大小的字符串。规定可以是
0
一个空白符和其他任意以单引号为前缀的字符,默认使用空白符填充。
86
4
字符串
2
一个正负号。正负号在字符串和数字上的作用是不同的。对于字符串,负号( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow
Java持续交付

Java持续交付

Daniel Bryant, Abraham Marín-Pérez

Publisher Resources

ISBN: 9787121404634