View
218
Download
2
Embed Size (px)
DESCRIPTION
Book about something
PHP
2012
PHP.
PHP. , Creative Commons Attribution-NonCommercial-ShareAlike ( ) 3.0 .
4
5 PHP
19
22
26 JavaScript
30 MySQL
40 CSS
44 JQuery
47 HTML
51
PHP.
, , PHP-, - , , . - ? . MyISAM InnoDB jQuery- $(a[rel~=external]) ~. , , , -, , , -, - , , , . , , -, . , HTML, JavaScript, PHP, , MySQL, - JQuery CSS... ?
100- , - , .. - . , .. , , ! , , , . , , - PHP -. - ! , , , , .
? , , - PHP- WEB-, , . , -, .. , , :
, ;
, ;
.
, . 9 : PHP, -, , JavaScript, MySQL, CSS, JQuery, HTML .
!
e-mail: jeffjoellennox@mail.ruSkype: AndriiShevchenko
PHP.
1. PHP1. sort(), asort() ksort()?
1) sort() . . .
2) asort() , -- . , , .
:
$capitals = array(US => Washington, UK => London, Austria => Vienna);asort($capitals);
// $capitals = {UK => London, Austria => Vienna, US => Washington}
3) ksort() . :
ksort($capitals);
// $capitals = {Austria => Vienna, UK => London, US => Washington}
2. ?
, . .
:
$var = first;$$var = Second;
// $$var == $first == Second
$$var , $var. , :
$first = second;
$second = third;print $first; // second
print $$first; // third
3. PHP?
1. PHP header()
header(Location: .$url);
PHP.
2. JavaScript
echo ; echo window.location.href=.$url.;; echo ;
4. PHP.
E_ERROR. , - .
E_WARNING. , -.
E_PARSE. , .
E_USER_WARNING. , . - trigger_error().
E_COMPILE_WARNING. Zend. -.
, PHP5 E_STRICT, - PHP.
5. PHP?
, - . , , , :
:
static final
.
Zend Engine 2.
6. ?
, . , $str , - , - .
PHP.
7. PHP?
PHP , , . - . , PHP .
8. ?
PHP 8 .
4 :
boolean. , true false.
integer. , (...-2, -1, 0, 1, 2...) -2^31 +2^31. - float.
float. , , .
string. . . PHP , .
2 () :
array. , .
object. , ( ).
2 :
resource. , .. . - .
NULL. , - . . - .
9. static ( static)?
Static , . , , .. .
. , , - ( ). , $this
PHP.
, .
->.
10. self this php?
self , this .
11. ?
PHP ( 5) __construct(), - new . , , . - , , new, - .
12. .
13. ?> ?
14. ?
, PHP-, ?> . PHP - .
15. ?
, PHP . . __call() -.
16. require(), require_once(), include() include_once()?
require() , require_once() , ( ).
PHP.
, require_once() , - . , .
require() include() : require() FATAL ERROR, , include() WARNING.
include_once() , include(), , require() require_once().
17. echo print PHP?
-, echo , print - . -, print 1, -.
18. eval() ?
eval() PHP-.
19. while do while?
do-while , - .
20. ? array(h, e, l, l, o), - array(o, l, l, e, h)?
PHP array_reverse().
21. ?
, :
22. ?
strrev(), , :
for ($i = strlen($str); $i>=0; $i--) $rev[] = $str[$i];$revstr = implode (, $rev);echo $revstr;?>
, :
:
23. ?
, ( ) ( ), , A B, B A. .
24. , .
PHP.
10
25. ?
26. PHP JavaScript. 123 + abc. ? 123 + abc?
JavaScript + , .. . PHP 123. PHP , , 10 + 20, , 30.
27. PHP?
, . Chimay, $beer.
28. . ?
: print_r.
:
29. count() sizeof()?
count() , sizeof() , . , - count() :
PHP.
11
, count() ;
, , 1;
, 0.
30. ?
, , . - . :
$people[] = ;$people[] = ;
$people[] = ;
31. :
:
input . upload.php, :
32. HTML-, text textarea. HTML- -- script1.php, data.txt . data.txt :
text1text2
text3
text4
text1 text3 text, text2 text4 textarea. , script1.php ,
PHP.
12
index.html.
:
Go : :
:
33. switch, boo, . 2, , 3 , --.
PHP.
13
34. $arr = array(3,8,15,25,16,11,10,5,7,30). - , 5.
35. , , .. 1.
P.S. ($k) true/false, , .
36. 3 0 10. 14, .
PHP.
14
37. .
2 -. : () , ( ).
38. $a?
$a = 1; $a[$a] = 2; echo $a;1239. a = array( ). for (i=0; i=0; i--).
40. array(1,2,3,4,10,100,3,4987,6,7,8,9).
max():
$arr = array(1,2,3,4,10,100,3,4987,6,7,8,9);echo max($arr);
:
41. -, - fuck, idiot bitch f**k, id**t bi**h.
$user_input = $_POST[user_input];$user_input_new = str_ireplace($find, $replace, $user_input);echo $user_input_new;}?>
42. ? ?
php, __.
:
__construct__destruct__call__callStatic__get__set__isset__unset__sleep__wakeup__toString__set_state__clone
__construct __destruct , -- : ;
__call, __callStatic, __get __set , , . __get() __set() , __call() __callStatic . , , ;
__isset , empty() isset() ;
__unset unset() - ;
PHP.
16
__sleep __wakeup , serialize unserialize -. __sleep serialize, __wakeup unserialize. (, );
__toString , (, print echo);
__set_state , , - var_export();
__clone ( - , - php5 );
__invoke .
43. , .
, :
:
echo .explode .htmlentities HTML .htmlspecialchars HTML .implode .ltrim .rtrim .trim .md5 MD5 .str_repeat .str_replace .str_split .strlen .strrev .
:
array_flip , _ , _ .shuffle ksort array_unique array_unshift array_sum array_shift array_reverse array_pop
PHP.
17
array_push array_keys array_count_values
:
filesize filetype fopen URLfwrite - is_executable , if_file , is_readable , is_uploaded_file , HTTP POSTis_writable , mkdir move_uploaded_file pathinfo readfile rename unlink
44. MySQL ?
mysql_num_rows(). SELECT. , INSERT, UPDATE, DELETE, mysql_affected_rows().
:
$result = mysql_query(SELECT * FROM table1, $link);$num_rows = mysql_num_rows($result);
echo $num_rows Rows\n;
PHP.
18
2.
1. MVC?
Model-view-controller , , , - . - , - .
2. MVC?
MVC, , : , -, .
, -.
, .
, - . . , , .
3. () ?
, - . , -. - .
4. ?
1.
Abstract Factory ( ). , .
Factory Method ( ). - . .
PHP.
19
Singleton (). -, . , MVC, () .
Prototype (). - , . Prototype , , .
Builder (). - , - .
2.
Adapter (). . , .
Bridge (). , .
Composite (). . . , - , - , . SimpleXML jQuery.
Decorator (). -. .
Facade (). , - . . - , . , . .
Flyweight (). .
Proxy (). , , - ( ).
3.
Chain of Responsibility ( ). .
Command (). .
PHP.
20
Interpreter (). .
Iterator (). , - , - .
Mediator (). , .
Memento (). , .
Observer (). - , .
State (). , .
Strategy (). , . - . Strategy - -, .
Template Method ( ). - , .
Visitor (). , -. Visitor .
5. PHP Singleton.
3.
1. ? ?
- , . - (, JavaScript) -.
2. .1) . , , - , . , . .. - . ( ) . , - , .2) . , , , .3) . , . , , . , .
3.