Post on 04-Dec-2014
********************************************************** ! http://natahaus.ru/ This file was downloaded from natahaus.ru portal ********************************************************** http://www.natahaus.ru/ , . ! , . , . . . . . . , , , e-mail - .
PHP 5
""
- 2005
32.973.26-018.2.75 15 681.3.07 "" . .. . . .. "" : info@dialektika.com, http://www.dialektika.com 115419, , / 783; 03150, , / 152
, 15 5 "".: . . .: "", 2005. 320 .: . . . . ISBN 5-8459-0851-5 (.) Web- 5. Web, , . . . 5 Web > , Web- Apache !. , , 1 Web. 32.973.26-018.2/5
. , , , JOHN WJLEY&Sons, Inc. Copyright 2005 by Dialektika Computer Publishing. Original English language edition Copyright 2004 by Wiley Publishing, Inc. Allrightsreserved including therightof reproduction in whole or in part in any form. This translation published by arrangement with Wiley Publishing, Inc. For Dummies and Dummies Man are trademarks under exclusive license to Wiley Publishing, Inc. Used by permission. ISBN 5-8459-0851-5 (.) ISBN 0-7645-4166-8 (.) - "", 2005 Wiley Publishing, Inc., 2004
I. 1. 2. 3. II. 4. 5. 6. III. 7. 8. 9. - IV. - 10. Web- 11. Web- 12. 13. 14. V. 15. , 16. Web- VI. . . 16 19 21 29 43 55 57 72 89 113 134 148 165 167 188 207 231 250 263 265 270 273 275 293 310
, 16L6 16 17 17 18 19
I. 1. Web- Web 5 2. Web- Web- Web- - 3. HTML- Web
:> ::>2 :>2
:>
:4
::5 :>
:>4
27 21 29 29
: :34 :i6 :\9 :\9 40 40 41 43 43 44 45 46 48 49 :0 :>1 :>2
II. 4. Web- 5. timestamp 6. echo list
55 57 57 58 58 59 60 61 62 63 63 63 64 66 66 67 67 68 69 70 72 72 72 73 74 74 76 78 79 79 80 81 81 82 85 86 87 89 89 89 91 92 92 93 94 95 95
7
foreach ( ) ( ) , $_SERVER $_ENV $argv $argc
!6 96 ( >7 98 98 '19 11)0 101 102 102 103 103 104 105 105 106 107 107 108 109
III. 7. if switch for while dcwhile 8. ()
1 [3 113 114 115 116 1L6 119 1: > 1 121 124 125 126 129 1: 1)1 1.32 134 155 135 136 137 138 138 140 141
8
9. - - - 5 - $this IV. - 10. Web- Web- , Web- Web- Web- HTML- Web- 11. Web- Web- Web- URL-
145 146 147 148 148 149 149 149 150 151 151 151 152 152 152 152 153 154 154 154 155 157 158 161 161 162 165 167 167 168 168 169 169 170 170 171 177 179 186 188 188 188 189 189 190 191 191
9
cookie HTML- JavaScript JavaScript JavaScript 12. ... SQLite 13. , system() () passthru() FTP FTP FTP FTP 14.
193 194 195 200 200 200 201 202 202 205 205 206 207 208 209 210 211 213 216 216 2]8 220 221 225 227 229 231 231 2 32 233 2 34 236 238 239 239 2 40 240 241 241 2 42 2 42 243 244 245 246 246 250 250 251
10
PEAR PEAR PEAR PEAR PEAR V. 15. , , 16. Web- Web- Zend Web-pecypc Builder Web- Black Beans PHP Web-pecypc PHP Dev Center Web- PHPMac .com Web-pecypc SourceForge.net Web- Web- VI. . Unix/Linux Unix/Linux Unix/Linux Apache Unix/Linux/Mac Apache Unix/Linux/Mac Windows CGI Web- Windows
254 255 256 258 259 263 265 265 266 266 266 266 267 267 268 268 269 270 270 270 270 271 271 271 271 271 271 271 272 272 273 275 275 276 276 278 280 280 281 283 284 286 287 289 290
11
. HTTP
293 2* '3 297 297 3(12 3(12 3(14 305 308 3.0
12
OJ atftftofie (Janet Valade) , Linux Web-. . Web Web- , . , , , , .
/ , .
'BUatoqafiHOCfHU . , , , . , , . .
/ , , . , , . , . . , Web- . , , , , . , , . . :E-mail: WWW: info@dialektika.com http://www.dialektika.com
:: : 115419, , / 783 03150, , / 152
, , . , , . . . , Web- . . Web-. , . , . , . . , , . . .
* : . . , . ( .) . , . . , Web, , . , , . , , .
, , . . , . \ , , . , , . : , , . , . , echo !, 2 . echo 3, 127
, ; . , . , echo !, 2, ... , .
nftec/, , , , , , , . , . , , , , . , , . . , Windows 95 , Mac OS 9. Windows 98 , . Web-, HTML (HyperText Markup Language). , . . HTML, , Web-. , HTML, , Web-. HTML. , Web-, , Web-. , Web-, Web. - . , . , , . . , , .
Gnfiifiantjfia , , .
I. " " . , .
II. " " . . . , , .
17
III. " " , , - .
IV. " -" , . , Web-, . , .
V. " " , , . Web-, .
VI. "" . , .
/, , . . , .
, .
! , (, , ) * .
^^?-
. , .
18
I
v
4w , (. ^obtpwiHHO Hi 006 .
3 / . . , . . . .
1
:> > >
, . , . , , . , , . , . , . , Web. , , Web-. . , , . , , . , .
U
. Web-. (Rasmus Lerdof), PHP Web- (Personal Home Page ). , . Hypertext Preprocessing, Web- . . / Web-. HTML-, , Web-, . S . , , , . S . . , HTML-.
S . PHP , Windows, Linux, Mac OS Unix. S . Web- (www.php.net), , , FHP, Windows . news . php . n e t . S . , . / . , , . , .
PHJ* . , , , "" . , , Web- . W:b, , Web-. , Web-, . Web-. , Web- (www.php.net/usage.php), 11 . Web- Yahoo!, , , , .
Web- Web- , .. . Web-, . , , . Web- . , Web-, . Web- . , Web- . , Web-. , . (server-side language) . , (, Web-.!). Web JavaScript. , JavaScript, ;. , JavaScript (client-side language). Web- " Web" . 22 I.
, HTML- Web-. , "" Web. , . , Web-. S HTML-. HTML- , . S . , , . J Web-. Web-, Web-. Web-. , , . , - , , , . , , . , JavaScript , . , JavaScript . , , . JavaScript Web-, , . JavaScript 11.
. , - . . - . , : , . : dBASE Informix Ingres Microsoft SQL Server mSQL MySQL Oracle PostgreSQL Sybase
/
1. PHP
23
, filePro, FrontEase InterBase. ODBC (Open Database Connectivity), , Access DB2. Web-, . PHP- . , Web-. , .
: , , : . , . , , , , . , , . Web- . , Web- , , , , . . , - , . .
:, . , d i r I s . . , , , , . , .. , * , . , , ? PHP-, , Peri, , (shell scripts). , , .
/ PHJ* . , . , . 24 I.
, , , , . . Web-, Web. , .
, CLI. . , . , Perl . , CLI, 3. World Wide W e b , " ", World Wide Web j (WWW). Web , Web-. j Web- . Web- " j ", , URL (Uniform Resource Locator ). URL Web- , ) www.mycompany.com/' w e l c o m e . h t m l . Web-, 1 URL- . . | 1. Web- Web . 2. , URL-, . 3. Web-, , . 4. Web- HTML-, URL- . 5. , Web- , ( ] , Web- .) 6. Web- HTML- Web-.
Web Web-, Web-. , Web- Web-. Web- , Web- " ". Web-. Web- (embedded scripting language). , HTML HTML, .. HTML-, , , . , Web- , PHP- . .php .phtml, Web- . , Web- HTML- . , PHP- , . 1. 25
HTML, FHP , , . . , . : IM. echo , HTML-. : 3, HTML-, . , , Web- . PrIP Web-, . Apache Software Foun iation, Web- Apache. Microsoft IIS/PWS, iPlanet ( Netscape Enterpiise Server) Web-. Web-I | | | j ! | j i , Web- " ", Web- (Web server). Web-, Apache. , w w w . n e t c r a f t . c o m w w w . s e c u r i t y s p a c e . c o m / s _ s u r v e y / d a t a / , 60% Web- Apache. Web- Apache , .. , . Linux Mac OS X. Wet Apache h t t p d . a p a c h e . o r g . Apache Software Foundation, : Web- Apache.
; Web-. Internet Information Serve r ! (IIS), 30% Web-. Microsoft, IIS- j Windows. . Web- Zeus, NCSA Sun ONE!. | Web- 2,5% Web-.
fne . , , Microsoft, Macromedia Adobe, , . , . , - , , , , . , , ? .
26
I.
. , , . , , . , , , . , , , , . . , , . Web- . , . , . , . (announcement mailing lists), . , , . , . , , Web- w w w . p h p . n e t / m a i l i n g - l i s t s . p h p .
5 , 5, . , . Zend ( ), , , . 5 - , 4. . , (exceptions). , - , , 5. (- 9.) 5 . Web p h p - c g i . PHP CLI php, p h p . exe Windows. , . 5 php. exe, . 5 MySQL 4.1 . , MySQL 4.0 MySQL 4.1 . 5 MySQL 4.0 . 5 SQLite, (flat files).
, . , , , . .
1.
27
S 4.3.1. , 4.3.0. Web- 4.3.0 . S 4.3.0. CLI, ( ). , . S 4.2.0. r e g i s t e r _ g l o b a l s Off. , , On , , . , . S 4.1.0. . , ( 6), . 4.1.0 , , , $HTTP_POST_VARS. , 5. Web- ! [ . .
28
I. PhP
2
/ ...> > > Web- Web- -
, , +S * Web-. , Web-, Web-. , Web, . , Web, " ".
Haanfiouica Web- 1, Web- Web. , Web- Web-. Web- . , , . Web- . . S Internet. S , , Web-. S , . , , , , . Web , . , Web-, . Web-, , - , , Web-. , Web-, . , , Web- - . Web-, - ( Web-
, Web-). , , Web- Web-, , Web-. Web-. S , . Web- . ; , . - . S . Web, HTML . Internet, Web-, . , . Web- . S . Web- . S . , . S . , , . , , , , , ;;, - . S . Web-, . . , . , .
Web- Web-, - , Web-. - , . Web-, . Web-. Web- Web-. S Web-. , Web- . Web-, Web- , . , , . S Web-. , . FTP . FTP (File Transfer Protocol) : .
30
I.
Web-. (user ) . S , . URL, . Web , , URL- . i n d e x . h t m i n d e x . h t m l , d e f a u l t . h t m . , , . S . Web- . .php .phtml, . . , . Web- . Web-, , , . , , , . , , , . , , . , , . , .
, Web-, . Web- , . . , . , , . , , Web-. , , 2 , , , 10 . , ( ). , . , , . , 3. 4.3.1 2003 , , 4.3.1 , . , 5.
2.
31
\
. S . , . , Bai jero . , , , . S . , , Web-. , . , Web- , ocof ioro . , . , ; . S . , . . . , . , < . S . , Web- . , (. ; , . , , Good Stuff , JanetsGoodStuff. J a n e t s G o o d S t u f f . com, , JanetsGoodStuff.Web-hostingcompanyname.com, JanetsGood S t u f f .Web-hostingcompanyname . com/~GoodStuf f, - . -, , . / . :. . , . , , . . (/) ? - ( ) . . Web- . , . . . , JanetGoodStuff.com, me@JanetGoodStuf f . com. 32 I.
. Web-. , , , MySQL PostgreSQL, Web-, FrontPage, , .. . Web- , , Web- .. S . (backup) Web- , . , . , - . Google "webhosting" 4 . , . , , . , , , .
*j
" "
. IP-. 0 255, , 1 7 2 . 1 2 . 2 0 4 . 2 .
IP- , . , IP- , , a m a z o n . com, www. i r e . g v m y c o m p a n y . com. , , (domain name). , , . , . , , t h o r . m y c o m p a n y . c o m , (subdomain) m y c o m p a n y . com. URL-, Web-, . URL- , , (, a m a z o n . c o m ) , . ( j a n e t . v a l a d e . com). , Web- ( i n d e x . h t m i n d e x , h t m l ) . , j a n e t . v a l e d . c o m / l i n k s . h t m l . , Internet. , . , . . ( ), . 35 . , .
2.
33
Web-, . Google " " 2 , i , . , . Web- , w h o i s . Allwhois ( A l l w h o i s . c o m ) Better-Whjis j
i (betterwhois.com).
. PHP- . . , , marc . t h e a i m s g r o u p . com/.
Web- Web- , . . Web- , , . . Web-, , . 1. . 2. Web-. 3. . . , , Web- ( ) . "", 9- , "". Web- , Unix Linux, Windows MacOS.
Web- , , Web- . , , Apache, . S . ? S . Apache Windows, Linux, MacOS, FreeBSD Unix. S . , www.netcraft.com/survey www.securityspace.com/s_survey/data/, 60% Web- Apache. . ! , .
34
I.
f . Apache , . . / . Apache, . / . , Apache SSL. SSL Web-, . , , Web- , , . . Apache Linux. , Apache . Unix Apache , (binary) ( ). Windows, ( Apache Windows NT/2000/XP, Windows 98/). , Apache 1.3.27. Apache 2 , . www. php. n e t . Apache, , , h t t p d . a p a c h e . org. Web-. Microsoft IIS (Internet Information Server), Internet: 27% Web-. Sun iPlanet ( Netscape Enterprise Server), 5% . . Linux. Mac OS X . , , . PHP-. .
PHP-, , . Web- . , Apache, . www. php. n e t . .
I
S Linux/Unix/Mac. f i n d / -name "php*" S Windows. ( ^) php*.
2.
35
- , , * . , , . | S . , . , , . : ODBC, MySQL, Oracle, MS SQL ; . , SQLite, XML, COM, FTP .., . , , , . , . , . , , phpinf (), , . , . , . . S . . . php-cgi -v , , 5, : php - v , , p h p - c g i . e x e ( php.exe). : 5.0.0 ( c g i - f c g i ) , Copyright () 1997-2003 The PHP Grotp Zend Engine v 2 . 0 . 0 . Copyright (c) 1998-2003 Zend Technologies , . ; www. php. n e t /downloads . php.
, . 1. , . . Apache h t d o c s . , Web-. IIS lnetpub\wwwroot. Linux /var/www/html. Web- , Web- - , , . , .
36
I.
2. t e s t . p h p : TecpoBaHne PHP HTML 3. URL- t e s t . p h p , . 2. URL h t t p : / / w w w . m y c o m p a n y . c o m / t e s t . p h p . Web, , URL- l o c a l h o s t / t e s t . p h p . A^'g^N , Web-, .
: HTML , . , , . p h p i n f ( ) . , , . p h p i n f () . - , . S HTML. . S . / Web-. , , , . . , , . , , php-cgi -v php - v
2.
37
, , , [. , , . 3. , , . 1. Apache h t t p d . c o n f DocumentRoot ":/Program Files/Apache Group/Apache/htdocs" Apache, Web-. . Web-) j a n e t . v a l a d e . com. , , , . , . . S Web- , IP. , h t t p d . conf AddType a p p l i c a t i o n / x - h t t p d - p h p .php S Apache, . php. ES , , . S h t t p d . c o n f , . , . S IIS, php. i n i : cgi.force_redirect = S p h p . i n i . , , . 1 0. , , , - Web-. , , , : . - , . marc . t h e a i m s g r o u p . com/. , - ) , . . . S S S S , . , . . , Web-.
, . 18 .
38
I.
Hactflftoutca THJ* qj& cu^Haftuetf PHP . Web- . CLI , Web-. . , CLI . , . . CLI p h p . e x e , a PHP CGI p h p - c g i . e x e . ( 5 php. , . CLI / c l i . ) , CLI - . . S Linux/Unix/Mac. : f i n d / -name "php*" S Windows. ( ) php*. , , - , CLI, , , : php -v , c g i c l i : 5 . 0 . 0 (cli) ( b u i l t : J u n 1 5 , 2003 2 3 : 0 7 : 3 4 )
, ( c l i ) . Web, ( c g i ) . CLI. , , , . CLI, . , Web. , CLI. Web-, , PHP- Web CLI. , .. 5.0.0 Web, , CLI 5.0.0. Windows p h p 5 t s . d l l , . , p h p 5 t s . d l l . ( .)
Hacfnftoutca THJ* . . , . -
2.
39
p h p . i n i . , . , php. i ai. , . , . , (, ), php. i n i . 1 , . , . , , .
cfteqctn , PHT-cu^HafiueePHP- . , . v i , Notepad WordPad. , , . (Integrated Development Environment). , > > > HTML
, , . PHP- . , - . . - , . 1, , , . Web- , Web-. , Web-, . , Web-. , , Web- , . , . , , , . , . , . , , .
onefiatfiofioe !PH!P , . echo. . echo: echo ""; echo , (""). . echo (simple statement). (;). , ; ( , ). . , , . .
, . : Parse error: expecting ' , ' " or ' ; ' ' in f i l e . p h p on l i n e 6 , , . , , , .. . , . aHanj . , , . , . 553 , . , , . , > . . , . , ({ }). , . , i ; . : if (_ == ){
; ; ;}
, . , .. _ = , , . ( , , ). , (, , i f ) , (complex statement). , . . , , . . , , . , ci ;, , . , . .
/ , .php. , , . , . 44 I.
Web- - HTML- Web-. Web, , . , . | HTML ( . h t m l . h t m ) , Web- : . , , H T M L Web-. | ( . p h p ) , Web- ( ). . 1. Web- HTML, .. i HTML, . | 2. HTML , | (). | 5. ?>, Web- HTML , . 1.
HTML- Web- HTML- Web-. . php, Web- . ( Web , , .php4 .phtml. .php , .) HTML , , HTML. :
, . , php . i n i . . , Web- , , PHP- , .. .
3.
45
, , Web- . ) ICT , Web-. , , (.. ) HTML . . , HTML . . php:
Web- . php .
HTML
.
Web , . Web. CLI (Command Li ie Interface ). CLI , Web- ( CGI), . CLI CLI , , ; , Unix Linux. , Windows, ( ). CLI Linux/Unix, Windows. ( .) :
46
I.
i 4> 4^:
Linux/Unix
(shell script) Perl 1 Linux/Unix, PHP- . , CLI, :
#! /usr/bin/php \
1
| , , / u s r / b i n / p h p . Windows , . # ! / u s r / b i n / p h p Linux/Unix, | , Windows . I . , | j , . , , ' | , t e s t . p h p ,
j test.php ; :
/mystuff/test.phpj He , , , .
t e s t c l i .php, ( , , CLI): php t e s t c l i . p h p :/usr/local/php/cli/php testcli.php
Windows, . StartoPrograms^Accessories^Command Prompt (^^1^ ). CLI CGI . S HTTP. CGI Web-, , HTTP (, Web- ). , CGI :Content-type: text/html X-Powered-By: PHP/5.0
, Web-. , CLI HTTP, :
3.
47
S . PHP CGI HTML, , , . PHP CLI . / argc arirv. a r g c a r g v ( ). CGI, CLI , . CLI 31. ( a r g c a r g v 5.) (). , - v . : php -v . 3.1 . 3.1. - p h p . i n i . CLI p h p . i n i , - / u s r / l o c a l / p h p / c l i / p h p . i n i ( p h p . i n i .) . , php - , p h p i n f () (. 2) -1 - - -v , . ( 14.) , . , php - r ' p r i n t ( ' ' ) ; ' /myfiles/testcgi.php
- -h -i
/ nefi0oio / THJ* , > , . HTML, , , : HTML-nporpaMMa 3, !
, :, !
48
I.
. , HTML PHP- , ! CueHaprai P H P < / t i t l e x / h e a d > , HTML. , , .. File^OpenO Browse (^). URL- (. 2). , , , URL-. :
echo, , (" "). , :3, !
PHP- , HTML-. , , , ( , View=>Source ( HTML-)).
2)1
PHP HTML-. , . : , :
, . , , . , h e a d e r () , . , .
/ (0), , (1). . : $ t e s t = 1; while ( $ t e s t
/ , . . : if ( i s s e t ( $ t e s t ) . , , , . :while ($test 4)
268
V.
{
echo "";} }
, , . , ? , , , , while, if. . : while ($test 4)
echo ""; } # if, $test3 } # if, } # while
$ t e s t 2
J[lffnaHUl4,a
ICfllfZMrtJlU U CpUZCfflHtxlMU
, , . , , , . ( {. .
15. , ... 269
16
Web- / uaie...> >
. Internet . . , .
Web-i/ PMJ* Web- , , . www.php.net
fiaccbtuicu THJ* , , ( Lis :s). , . , , . , p h p - g e n e r a l ( , ), php-db ( ), p h p - i n s t a l l ( ), php-windows ( Windows) .. . . . , , . , . www.php.net/mailing-lists.php
1* Internet). 2. Web-. 3. Properties (). 4. Home Directory ( ). 5. Configuration (). 6. Mappings. 7. Add (). 8. Executable , c:\php\php-chi.exe. 9. Extension () . php. . 10. Script Engine. 11. . 6-10, , (> , .phtml.
292
VI.
, . . , .
/ fiatfoffibi .
array (. 6). : $ a r r a y = array{=>, =>, . . .) ; =>,
array_count_values() , . : $ a r r a y _ o u t = a r r a y _ c o u n . t _ v a l u e s ( $ o r i g _ a r r a y ) ; , $ o r i g _ a r r a y $ o r i g _ a r r a y [ a ] = $ o r i g _ a r r a y [ b ] = $ o r i g _ a r r a y [ c J = $ o r i g _ a r r a y [ d ] = a r r a y _ c o u n t _ v a l u e s () $ a r r a y _ o u t : $array_out[] = 2 $array_out[] = 1 $array_out[] = 1
array_diff() $1, $2, $ .. (. 6). :$array_out = a r r a y _ d i f f ( $ 1 , $2, $, ...);
array_intersect() , . :$simArarray = a r r a y _ i n t e r s e c t ( $ 1 , $2, ...);
_ () $ o r i g _ a r r a y . _, , _. : $ a r r a y _ o u t = a r r a y _ k e y s ( $ o r i g _ a r r a y , "_"); , $ o r i g _ a r r a y $ o r i g _ a r r a y [ a ] = $ o r i g _ a r r a y [ b ] = OR $ o r i g _ a r r a y [ ] = TX $ a r r a y _ o u t : $array_out[0] = $array_out[1] = b $array_out[2] = _ OR, .. a r r a y _ k e y s () : $array_out = a r r a y _ k e y s ( $ o r i g _ a r r a y , OR); $ a r r a y _ o u t $array_out[0] = b array_merge ( ) . , (. 6). : $bigArray = _ ( $ 1 , $2, ...); array_merge_recursive . , (. 6). : $bigArray = array_merge_recursive {$1, $2, . . . I ; _() . : $element = a r r a y _ p o p ( $ o r i g _ a r r a y ) ; array_push() . : $new_size = a r r a y _ p u s h ( $ o r i g _ a r r a y , "2", "2", ""); array_reverse() $ o r i g _ a r r a y . : $ a r r a y _ o u t = a r r a y r e v e r s e ( $ o r i g _ a r r a y ) ; array_search() $ o r i g _ a r r a y , , , FALSE. : $key = a r r a y _ s e a r c h ( " " , $ o r i g _ a r r a y ) ;
294
VI.
array_slice() $subArray $ o r i g _ a r r a y , (. 6). : $subArray = a r r a y _ s l i c e ( $ o r i g _ a r r a y , , ); array_sum() (. 6). : $ sum = a r r a y _ s u m ( $ o r i g _ a r r a y ) ; array_unique() (. 6). : $ a r r a y _ o u t = a r r a y _ u n i q u e ( $ o r i g _ a r r a y ) ; arsortO $ o r i g _ a r r a y (. 6). : a r s o r t ( $ o r i g _ a r r a y ) ; asort() $ o r i g _ a r r a y (. 6). : a s o r t ( $ o r i g _ a r r a y ) ; compact() ($varl, $var2 ..). , . : $ a r r a y _ o u t = c o m p a c t ( $ v a r l , $ v a r 2 , ...); count() $ o r i g _ a r r a y (. 6). :$size = c o u n t ( $ o r i g _ a r r a y ) ; current () $ (. 6). : $value = c u r r e n t ( $ a r r a y ) ; end () $ a r r a y (. 6.) : $ v a l u e = e n d ( $ a r r a y ) ; e x p l o d e () . sep ( ) (. 6). : $ a r r a y _ o u t = explode ("sep", $ s t r i n g ) ; extract() . (. 6). : e x t r a c t ( $ a r r a y ) ;
.
295
implode() , , sep (. 6). : $ s t r i n g e x p l o d e ( $ a r r a y , "sep");
in_array() $. , TRUE, FALSE. : $bool = i n _ a r r a y ( " " , $ a r r a y ) ; key () $ a r r a y . : $key = key ( $ a r r a y ) ,-
key_exists() $. , TRUE, FALSE. : $bool = k e y _ e x i s t s ( " " , $ a r r a y ) ;
ksort,
krsort()
. k s o r t () , k r s o r t () (. 6). :ksort($array); k r s o r t ( $ a r r a y ) ;
tsort(),
natcasesort()
"" . , n l , 2, 12, 25, n l , 12, 2, 25, . n a t c a s e s o r t () . : n a t s o r t ( $ a r r a y ) ; n a t c a s e s o r t ( $ a r r a y ) ; next () $ (. 6). : n e x t ( $ a r r a y ) ;
prev() $ (. (). : p r e v ( $ a r r a y ) ;
range () . ! 1 (, 1-10) ( - - ) . :$array_out = r a n g e [ , ); reset() $ (. 6). : r e s e t ( $ a r r a y ) ;
sizeofO $ (. 6). :$size = s i z e o f ( $ a r r a y ) ;
296
VI.
sort (), rsort () . s o r t () , a r s o r t (. 6). :sort($array); r s o r t ( $ a r r a y ) ;
/ ftarfotnu / . check.da.te ( ) TRUE, , FALSE . :checkdate(, , ) ; date , gmdate() , $timestamp Unix, . gmdate () . : $ f o r m a t t e d _ d a t e = d a t e ("", $ t i m e s t a m p ) ; getdatei) , , , , .., $timestamp Unix. : $ a r r a y _ d a t e = g e t d a t e ( $ t i m e s t a m p ) ; localtime() , , , , .., . : $ a r r a y _ d a t e = l o c a l t i m e ( $ t i m e s t a m p ) ; microtime() , 1 1970 . : $time_out = m i c r o t i m e O ; mktimeO, gmmktime() Unix . gmmktime () (. 5). : $timestamp = mktime(4acbi, , , , , ); t i m e ; Unix (. 5). : $ t i m e s tamp = t i m e ;
(ptfMJcuuu fiaJotnbi . basename() (. 13). : $filename = basename ("") ;
.
297
cbdirO __ : c h d i r (" __") ;
(. 13).
chgrpl) , . : c h g r p (" __", " ") cbmod() . : chmod("__", cbownO . : chown (" __",
;
"_") ;
" _")
;
closedirO $dh (. 13). : c l o s e d i r ($dh) ; copy () (. 13). : (" _",
" _") ;
dirnaiae ( ) (. 13). : $ d i r e c t o r y _ n a m e = dirname("") ; dis_total_space() . : $space = d i s _ t o t a l _ s p a c e ("") ; diek_free_space() . : $f = d i s k _ f r e e _ s p a c e ("") ; flose() $fh (. 12). : f c l o s e ( $ f h ) ; feofO TRUE $ fh (. II). : feof ($fh) ; fgetc() () $f h -: . : $ c h a r = f g e t c ( $ f h ) ; fgetcsv() , - sep (. 12). : $ a r r a y _ o u t = f g e t c s v ( $ f h , , "sep");
298
VI.
fgets(), fgetssO $fh . , f g e t s s () (. 12). : $ l i n e = f g e t s ( $ f h , ); $ l i n e = f g e t s s ( $ f h , ); () , (. 12). : a r r a y _ l i n e s = f i l e ( $ f h ) ; file_exists() (. 13). : $bool = f ile_exists("__") ; fileatimeO (. 13). : $timestamp = f i l e a t i m e ("__") ; filectimeO (. 13). : $timestamp = filectime("__"); filemtimeO (. 13). : $timestamp = f i l e m t i m e ( " __") ; flleownerO - (. 13). : $userID = f i l e o w n e r ("__") ; f () , . : $perms = f i l e p e r m s (" __") fllesizeO (. 13). : $ s i z e = f i l e s i z e ( " _ _ " ) ; filetypeO , (. 13). :$type = f i l e t y p e ( " _ - " ) ; flock () (. 12). : f ilelock("__") ; fopen () (. 12). : $fh = fopen (" __", ); fput () . FALSE, (. 12). : $ r e s u l t = f p u t s ( $ f h , "", ); . 299 file
;
fremdO , (. 13). :$file_content = f r e a d ( $ f h , ); fscant() . ( . 13.) :$string = f s c a n f ( $ f h , "", $ v l , $v2, . . . ) ; seek() $f h . : SEEK_SET ( ), SEEK_CUR ( ) SEEK_END ( ). : f seek ($fh, , ); fwriteO $f h. (. 12). : $ b y t e s _ w r i t t e n = f w r i t e ( $ f h , "", ); getcwdO , . : $ c u r r e n t _ d i r e c t o r y = g e t c w d O ; getlastmodO . : $timestamp = g e t l a s t m o d O ;
is_dir() TRUE, , FALSE (. 13). : $bool = i s _ d i r ( "") ;
is_file() TRUE, , FALSE (. 13). : $bool = i s _ f i l e ( "") ; is_readable() TRUE, , FALSE (. 13). : $bool = i s _ r e a d a b l e ("__") ; is_uploaded() , Web . :$bool = is_uploaded("__"); is_writable() TRUE, __ { , FALSE (. 13). : $bool = i s _ w r i t a b l e ( " __") ;
300
VI.
mkdlrO , . : mkdir (" ___", ) ; movm_\iploadmd_lle() (. 11). : move_uploaded_f i l e ( "_", ""); opendir() (. 13). : $dh = o p e n d i r (" __"); paasthru() (. 13). : p a s s t h r u (" _") ; pathinfoO , : dirname (), basename ( ) e x t e n s i o n (). : $ a r r a y _ d i r = p a t h i n f o f "") ; readdirO (. 13). : $filename = r e a d d i r ($dh) ,readfilm() . . URL. :$numberOfBytesRead = r e a d f i l e ( " _ _ " ) ; rename . :rename("_",
"_");
rewind $f h . : rewind($fh) ; rmdirO (. 13). : rmdir (" __"); tmpfileO , . : $fh = t m p f i l e O ; touch() . , . , . : $bool = t o u c h (" __", ); . 301
unmask () , , . . : $old_mask= unmask () ; unlink() (. 13). : u n l ink (" __")
;
/.fraJbifUrt /
HJT? HTTP . tjbrowser () . : $ s t r i n g = get_browser("") ; get_meta_tags () , , . :$array_tags = get_meta_tags("__"); header() HTTP Web- (. 10). : h e a d e r (" _") ; mail() (. 13). : $ s u c c e s s = m a i l ("", " _", "", " ") ; parse_url() , URL-, , , , .. : $ a r r a y _ u r l = parse_url("aMpec_URL"); setcookie() cookie (. 10). : s e t c o o k i e ("", "", "", _);
_,
"",
Uia/neyiariiuHecteue . , cos (), t a n () p i ( ), .
302
VI.
aba () . : $ a b s o l u t e = abs () ; blndecO . : $number_decimal = b i n d e c (_) () , . : $number = () ; floorO . : $ i n t = floor {) ; bexdecO . : $number_decimal = h e x d e c ( ) ; log() . : $ log = l o g {); loglOO 10 . : $ l o g l 0 = loglO {) ; max () . . : $num_large = max($array) ; $num_large = max(1, 2, . . . ) ; join ; . . : $num_min = m i n ( $ a r r a y ) ; $num_min = m i n { 1 , !, ...) ; number^format () - . (.) (,) (. 5). : $ f o r m a t t e d = number_format{, "_", "_"); octdecO . :$number_decimal = o c t d e c ( ) ;POw()
;
, . :$result = pow(, ); . 303
rand () . : $number_rand = rand(, ); round() . : $ r e s u l t = round{, _); aqrt () . : $ s g u a r e _ r o o t = s g r t (); arand() . : srand(_) ;
qua fuzJoriibi /&/ . gmtmnvO . : $environment_value = getenv("__" gmtlaatmodO . : $timestamp = g e t l a s t m o d ( ) ; ini_gat () . : $ s t r i n g = i n i _ g e t ( " " ) ; ini_set() (. 4). : i n i _ s e t ("", " ") ; pbpinfoO (. 4). : phpinf ( ) ; phpvmraionO . : $ v e r s i o n = p h p v e r s i o n O ; putenvf) . _= . : p u t e n v (" ") ;
I;
304
VI.
. addBlaeheeO / , \ 0 . :$string_escaped = a d d s l a s h e s ( " " ) ; base64_encode, base64_decode() / base64 (. 13). : $ s t r i n g _ e n c o d e d = base64_encode(""); chop () . :$chopped = chop(""); chr() ASCII, . : $char = c h r (KOUJUSCII) ; count_chara() , $ s t r i n g , . .. $ s t r i n g . :$array = c o u n t _ c h a r s ( $ s t r i n g , ); mchoO (. 3). : echo !, 2, ,
...;
eregO, eregiO $ s t r i n g , . e r e g i () (. 7). : $bool ereg("", $ s t r i n g ) ; ereg_replace(), eregi_replace() $ s t r i n g , , . e r e g _ r e p l a c e ( ) , e r e g i _ r e p l a c e () (. 7). : $new_string = ereg_replace(ereg_replace("", "_", $ s t r i n g ) ; explode() , $ s t r i n g , -. : $ a r r a y _ o u t = explode ("", $ s t r i n g ) ; htmlmntitima() $ o r i g _ s t r i n g HTML . : $ s t r i n g _ o u t = h t m l e n t i t i e s ( $ o r i g _ s t r i n g ) ;
5.
305
htmlspecialcbara
()
$ s t r i n g HTML, , , & &. : $ s t r i n g _ o u t = h t m l s p e c i a l c h a r s ( $ s t r i n g ) ;
implode() $ . : $ s t r i n g _ o u t = implode ( $ a r r a y , "");
nl2br() $ s t r i n g
(\). :$string_out = n l 2 b r ( $ s t r i n g ) ;
ord() ASCII- . : $ i n t e g e t = o r d ( " ") ;
parse_url
()
, URL-. : $ a r r a y = parse_url("anpec_URL");
print() , . : p r i n t ;
printfO (. 5). : p r i n t f ("", !, 2, , ...;
split
,
splitiO
, $ s t r i n g . s p l i t i () . : $ a r r a y = s p l i t ("", $ s t r i n g ) ; $ a r r a y = s p l i t i ("", $string);
sprintf
()
, (. 5). : $ s t r i n g = s p r i n t f ("", 1, 2, , . . .) ;
str_pad() $ s t r i n g . : $ s t r i n g = s p r i n t f ( $ s t r i n g , , "");
str_repeat() $ s t r i n g , . : $ s t r i n g _ o u t = s t r _ r e p e a t ( $ s t r i n g , );
306
VI.
str_repla.ce () _ $ s t r i n g __. : $ s t r i n g _ o u t = str_replace("_", "_", $string); strchrO, strrchar () s t r c h r O $ s t r i n g , , a s t r r c h a r () . :$string_part = s t r c h r ( $ s t r i n g , ""); strcmpl), strcasecmp() . $ s t r l $ s t r 2 , 1, - 1 . , 0. strcmp () , a s t r c a s e c m p () . : s t r c a s e c m p ( $ s t r l , $ s t r 2 ) ; strcapnO $ s t r i n g . : $ i n t = s t r c s p n ( $ s t r i n g , ""); strip_tasrs () $ s t r i n g HTML . _ , (. 10). : $ s t r i n g _ s t r i p p e d = s t r i p _ t a g s ( $ s t r i n g , "_"); strlenO $ s t r i n g . : $ l e n g t h = s t r l e n ( $ s t r i n g ) ; strposO, strrpos() s t r p o s () $ s t r i n g , a s t r r p o s () . :$integer = s t r p o s ( $ s t r i n g , ""); $integer = strrpos($string, "");
stratrO,
stristri)
$ s t r i n g , . s t r s t r () , s t r i s t r () . :$str_part = s t r s t r ( $ s t r i n g , ""); $str_part = s t r i s t r ( $ s t r i n g , ""); strtolower(), strtoupperO $ s t r i n g . : $ s t r _ l o w e r = s t r t o l o w e r ( $ s t r i n g ) ; $str_upper = s t r t o u p p e r ( $ s t r i n g ) ;
.
307
mtrtrl) $ s t r i n g _ _. : $ s t r i n g _ o u t = s t r t r ( $ s t r i n g , "_", "_"); subBtrO $string _. : $ s t r i n g _ n e w = s u b s t r ( $ s t r i n g , , _);
Bubatr_replace() $ s t r i n g _ _. : $ s t r i n g _ n e w = s u b s t r _ r e p l a c e ( $ s t r i n g , "_", , _) ; trlmO, ltrimO, rtrimO t r i m ( ) $ s t r i n g , l t r i m ( ) , a r t r i m () . : $ s t r i n g _ n e w = t r i m ( $ s t r i n g ) ;
ucfirst() $ s t r i n g . : $ s t r i n g _ n e w = u c f i r s t ( $ s t r i n g ) ; ucwordsO $ s t r i n g . : $ s t r i n g _ n e w = ucwords ( $ s t r i n g ) ; wordwrap () $ s t r i n g (\\) . :$string_new = w o r d w r a p ( $ s t r i n g , _) ;
fia^OfHH . empty () , $varname - (. 7). : $bool = empty ($varname) ; g-et__de ined_classes () , ( ). : $ a r r a y _ c l a s s e s = get_def i n e d _ c l a s s e s () ; gat_dafined_constant*() .
308
VI.
: $ a r r a y _ c o n s t a n t s = g e t _ d e f i n e d _ c o n s t a n t s ( ) ; Sret_defined functions () . : $ a r r a y _ f u n c t i o n s = g e t _ d e f i n e d _ f u n c t i o n s ( ) ; get_defined_vare() . :$array_vars g e t _ d e f i n e d _ v a r s ( ) ; issat () , $varname (. 7). : $bool = i s s e t ($varname) ; print_r() $varname (. 4). : p r i n t _ r ($varname) ; putenvO . =. : p u t e n v (" ") ; _*
serialize() . . $ v a r i a b l e , . : $ s t r i n g _ s e r = s e r i a l i z e ( $ v a r i a b l e ) ; unserialize() . : $ v a r i a b l e = u n s e r i a l i z e ( $ s t r i n g _ s e r ) ; set() $varname (. 4). : u n s e t ($varname) ; var_dvmp() (. 4). : var_dump ($varname) ;
.
309
Emacs, 41 Embedded scripting language, 25 Error message, 67 Exception, 27 Extension, 250
Access, 24 Apache, 34; 275 Arachnophilia, 41 ASCII-, 115 Attribute, 149
BBEdit, 41 BCMath, 250
C, 24; 60 Character string, 78 Class, 149 CLI, 39 Client-side language, 22 Command Line Interface (CLI), 46 Complex statement, 44 Concatenation, 81 Condition, 114 Conditional statement, 114; 121 Constructor, 154 cookie, 191 Core, 250 CSV, 213 ctype, 251 cURL, 252
File, 231 handle, 209 Transfer Protocol (FTP), 30 filePro, 24 Flat file, 27 Folder, 231 FrontBase, 24 FY?, 241 Function, 138
GET, 178
Hheredoc-, 78 Hidden field, 195 HomeSite, 41 HTML-Kit, 41 HTML-, 170 Hypertext Preprocessing, 21
DData Source Name (DSN), 260 Database, 216 Management System (DBMS), 216 dBASE, 23 Directory, 231 handle, 235 Domain name, 33 Dreamweaver MX, 42
EE_ALL, 66 EditPlus, 41
IBM DB2, 24 IIS, 275 \ Infinite loop, 131 Informix, 23 Ingres, 23 Inheritance, 150 Instantiation, 152; 157 Integrated Development Environment (IDE), A 0 InterBase, 24 Internet Information Server (IIS), 35 IPlanet, 35 IP-, 33
JJava, 60 JavaScript, 22; 205
Key, 89 Komodo, 42
PHPUnit, 255 -, 43; 113 Polymorphism, 151 POST, 178 PostgreSQL, 23 Property, 149 PWS, 291
Q LQuery, 220
localhost, 222 Loop, 114
R MRegular expression, 116 Responsibility, 149 Returning value, 140
Maguma, 42 Master class, 150 Method, 149 Microsoft SQL Server, 23 mSQL, 23 Multiple inheritance, 151 MySQL, 23; 259
sSecure Sockets Layer (SSL), 35; 170 Server-side language, 22 Session, 195; 207 ID, 195 Shell script, 24 Simple Mail Transfer Protocol (SMTP), 245 statement, 43 SQLite, , 27; 208; 229; 251 Structured Query Language (SQL), 220 Stuffit Expander, 281 Subclass, 150 Subdomain, 33 Sybase, 23
NNesting, 124 Net_SMTP, 255 Netscape Enterprise Server, 35 Notice, 67
Object, 148 Open Database Connectivity (ODBC), 24; 216 Oracle, 23 Output statement, 49
TTextWrangler, 41 timestamp, 85 tokenizer, 251 TSV, 214 Type casting, 73
PPackage manager, 256 Parent class, 150 Passing by reference, 144 PEAR (PHP Extension and Application Repository), 250; 254 Perl, 24 Personal Home Page, 21 PHP CGI, 39 CLI, 25; 27; 275 PHPEdit, 42
Uniform Resource Locator (URL), 25
VValidating information, 179 Variable, 57
311
wWarning message, 67 WDDX, 251 Web-, 29 Web-, 21 Web-, 25; 26; 29 whois, 34 World Wide Web (WWW), 25
, 248 , 189 PHP, 45 , 235 , 209 include_path, 138 Indexes, 169 trans-sid, 196; 198 upload_tmp_dir, 201 , 52 , 32; 33
XXML_Parser, 255
zZend, 27 Studio, 42 zlib, 251
3 , 200 , 220 , 143
A , 107 , 90 PHP, 250 , 149 maxlength, 174
, 57 , 232 , 195 , 113 , 57 , 89 , 152; 157 , 40 , 41 , 25 CLI, 46 , 27; 161
, 23; 216; 259 , 131 , 44 , 168
, 135 , 124 , 53 , 140 , 66 , 107; 177; 201 , 25
, 79 , 231 , 149 Exception, 161 , 152 , 150 , 22 , 89 , 64 , 52; 53 , 81
, 161 , 140
312
, 63 E_ALL, 68 , 66 , 154 , 161
, 72 , 140
, 56; 89 $_1, 194 $_FILES, 201 $_GET, 192 $_SERVER, 107 $_SESSION, 196 , 107; 177 , 104 , 28 , 256 , 149; 154 clone(), 161 _destruct(), 162 , 158 , 178 , 104 , 151 mod_so, 276 PEAR, 254
- , 27; 148 , 149 , 159 , 43 break, 132 define, 63 echo, 43; 59; 62 foreach, 97 if, 121 switch, 124 , 49 , 43 , 44 , 114 , 24; 236 , 72 , 217 , 24
PEAR-DB, 259 , 259 , 231 , 141 , 144 , 57 $this, 154 , 62 -, 126 , 188 , 21 , 134 , 33 , 150 , 151 , 75 , 67 , 73 , 73 , 179 , 72 FTP, 30; 241 SMTP, 245 SSL, 35; 170
, 150 , 150 Web-, 34
, 27 , 45 , 66; 147; 161 , 71 , 81 , 119 , 148
313
, 250 , 252 , 31 , 116; 180 , 41 , 33 , 150
, 231 CSV, 213 httpd.conf, 38 php.ini, 38; 40; 48; 67 , 248 , 69 , 229 , 24 , 23; 194 , 82 , 86 , 138 date(), 86 die(), 71; 147 echoO, 73 emptyO, 179 ereg(), 119 exit(), 70 includeO, 135 mail(), 246 my_error_handler(), j \ number_format(), 77 print_r(), 59 printf(), 77 require(), 136 strtotimeO, 87 system(), 239 , 83 HTTP , 302 , 297 , 293 , 304 , 308 , 297 , 302 , 141 , 94 , 305
, 149 , 191; 195; 207 , 22 Apache, 34 IIS, 35 iPlanet, 35 , 22 , 78 , 79 , 33 (), 216 , 195; 199 , 44 , 67 , 93 , 79; 117 , 189 , 72 , 28; 107 , 24; 47
, 78; 117 , 27; 208 , 72 , 116
, 67 , 162 , 96 , 67 , 68 , 114 , 114; 121 , 265 , 168
X , 31
, 72 , 114; 125
314
do..while, 130 for, 126 , 131 XT , 72
a , 250 Zend, 270 JavaScript, 22 , 22 , 220
, 43 , 244
315
I 0!
THT5//TM , 2
BESTSELL1NG
BOOKSERIES
qjL& "
,
$
( )
[ ]
\
+
4?*'
*
^*fn}
S. \^ 1 )
, , , ( ) , ()
ger?m
, , germ, gem geam
g(er)m
germ
Gem, grem
j[er]m
gem,grm
germ, gel
31 erjm
gym, gum
gem, grem, germ
g[a-c]m
gam, gbm, gem
gdm, gxm, gal
b l d g [ l - 3 ] 4 bldg111,bldg132
bldg,bldg555
ge*m
gm, geeem
germ,grm
ge{5}m (2,5)
geeeeem aa, aaa, aaaa, 145aaaaa
geeeem, geeeeeem 1,a3
g\*m (! )
g*m
gem, germ ,
BESTS ELUNG
BOOKSERIES
Scolors[] ""; Scolors [] = ""; Spaint ['house'] ""; S p a i n t P b a r n ' ] = "" array Scolors ("", ""); array Scolors array(5 > "", ""); array Spaint = a r r a y ( " b a r n " => "", "house" > ""); SpaintPhouse'H'tall'] ""; Spaintpbarn'jptall'] = ""; S p a i n t P h o u s e ' ] ["short') ""; SpaintPbarn'] ['short'] = "";
Scolors[l) = ; Scolors[2] - ; Spaint[house ] ; Spaint[barn) " ; Scolors[l] = ; Scolors[2] = ; Scolors[5] ; Scolors[6] ; Spaint[barn] - ; $paint[house ] = ; $paint[house][tall] ; $paint[barn][tall] = ; $paint[house] [short] ; Spaint[barn] [short] = ;
J^^
^5 ^S J 3 - 4J ^
One/iauuu
"" === > >= < < =!=
? , ? , ? , ? , ? , ? ? ? ?
nefieMHHbix !PH!P ($) , ,
!==
-
5 ""
.. . . .. , . .. , .. , ..
"". 101509, , . , . 43, . 1. 07.06.2005. 70X100/16. Times. . . . . 25,8. .-. . 18,72. 3000 . 1879. " " , . 197110, -, ., 15.