Tải bản đầy đủ (.pdf) (7 trang)

goodwithphp 9878

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.56 MB, 7 trang )


Rockablepress.com
Envato.com
© Rockable Press 2012
All rights reserved. No part of this publication may be
reproduced or redistributed in any form without
the prior written permission of the publishers.


3

Acknowledgement

Acknowledgement
There might be only one name on the cover, but no one writes a
book alone. I am eternally grateful to the following parties:
• God, for orchestrating not just the making of this book,
but my whole life, really.
• Dad and Mom — as well as my siblings and grandparents — for their support and encouragement throughout
the entire process. They were, and always have been,
willing springboards for ideas and invaluable advisors.
There’s no exaggeration in saying that without them, the
book wouldn’t exist.
• The whole Envato crew and contractors, but especially
Jeffrey, for taking me on as a writer when I’d never done
any tech- or tutorial-writing before and encouraging me
(whether he knows it or not) to continually become a better
writer and developer; Naysan, for suggesting I write this
book, and for organizing the legalities and logistics so
that I could focus on the writing; Peter, for being a meticulous editor, and reigning me in when I tried to do crazy
things with the English language; and the book design


and layout folks, who made all this tough-on-the-brain
teaching so easy on the eyes.
• And finally, you, the reader, without whom the efforts of
the aforementioned parties would be a complete waste.


4

Table of Contents

Contents
Acknowledgement3
Chapter 1

8

What is PHP?
8
Who is this Book For?
9
How Do You Install PHP?
10
Installing PHP on Windows
11
Installing PHP on Mac OS X
13
PHP on Your Server
15
The Example Files
16

Summary17

Chapter 2

19

PHP Files
19
Variables20
Values21
Strings22
Numbers23
Booleans24
Null24
Array24
Comments26
Operators27
Arithmetic Operators
27
The String Operator
28
Assignment Operators
29
Incrementing / Decrementing Operators
29
Comparison Operators
30
Logical Operators
32
Conditional Operator

34
Functions34
Code Style
36
Summary37


5
Chapter 3

Table of Contents

39

Control Structures
39
if and else (and elseif 
)39
for / foreach41
return / break / continue45
switch47
require / include / require_once / include_once49
Final Thought on Control Structures
52
PHP Internal Functions
53
String Functions
53
Breaking Up and Getting Together
54

A Case of Changed Case
55
Keeping Thing Trimmed
56
Replacements56
How Long?
57
Needle in a Haystack
57
Et Cetera
58
Array Functions
58
Pushin’ and Poppin’
58
Mappin’ and Walkin’
60
Searching High and Low
61
Slicin’ and Dicin’
62
Sorting Things Out
64
Counting Your Chickens (After They Hatch)
64
Summing it all Up
65
Date and Time Functions
65
parse_date65

time66
strftime66
Math Functions
67
max / min67
mt_rand67
round / ceil / floor68
JSON Functions
68
File Functions
69
fopen69
Reading a File
70


About the Author
Andrew Burgess is a Canadian web
developer, university student, and
staff writer for Nettuts+, where he
has published numerous popular
tutorials and screencasts. Andrew
is also the author of the Rockable
titles “Getting Good with Git,” and
“Getting Good with JavaScript.” As
a web developer, he specializes in
JavaScript and Ruby. Andrew lives
with his family in Oshawa, Canada.
Check out Andrew’s personal site:
Or follow him on Twitter: @andrew8088



Now that you’ve finished

Getting Good with PHP
check out these related eBooks from the
Rockable Press library:

Getting Good with
JavaScript

Getting Good with Git

by ANDREW BURGESS

by ANDREW BURGESS

MORE EBOOKS



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×