Ò»Ììѧ»áphp(ÉÏ)
ÎÒÕâÀï˵µÄÒ»Ììѧ»áÊÇÓÐÇ°ÌáµÄ£¬Ê×ÏÈÄãÐèÒªÓбà³ÌµÄ¾Ñ飨²»¹ÜºÎÖÖÓïÑÔ£©£¬»¹ÓÐÕâÀïÖ»ÊÇ˵ѧ»á£¬²»ÊǾ«Í¨¡£ÓÉÓÚÎÒѧϰphpÒ²ÊÇΪÁ˸ã¸ö¸öÈËÍøÕ¾ÍæÍæµÄ£¬²»ÊÇΪÁ˳Է¹µÄ£¬ºÇºÇ¡£
Ê×ÏÈ£¬½²Óï·¨PHPµÄÓï·¨¡£
ǶÈë·½·¨£º
ÀàËÆASPµÄ£¬PHPÖÐÒ²¿ÉÒÔ¡£Ò»°ãʹÓÃ<?php ?>ÕâÑùÐÎʽ
Âß¼ÔËË㣺
·ûºÅ ÒâÒå
< СÓÚ
> ´óÓÚ
<= СÓÚ»òµÈÓÚ
>= ´óÓÚ»òµÈÓÚ
== µÈÓÚ
!= ²»µÈÓÚ
&& ¶øÇÒ (And)
and ¶øÇÒ (And)
|| »òÕß (Or)
or »òÕß (Or)
xor Òì»ò (Xor)
! ²» (Not)
phpµÄÁ÷³Ì¿ØÖÆ
1. if..else Ñ»·ÓÐÈýÖֽṹ
µÚÒ»ÖÖÊÇÖ»ÓÐÓõ½ if Ìõ¼þ£¬µ±×÷µ¥´¿µÄÅжϡ£½âÊÍ³É "Èô·¢ÉúÁËijÊÂÔòÔõÑù´¦Àí"¡£Óï·¨ÈçÏ£º
if (expr) { statement }
ÆäÖÐµÄ expr ΪÅжϵÄÌõ¼þ£¬Í¨³£¶¼ÊÇÓÃÂß¼ÔËËã·ûºÅµ±ÅжϵÄÌõ¼þ¡£¶ø statement Ϊ·ûºÏÌõ¼þ
µÄÖ´Ðв¿·Ö³ÌÐò£¬Èô³ÌÐòÖ»ÓÐÒ»ÐУ¬¿ÉÒÔÊ¡ÂÔ´óÀ¨ºÅ {}¡£
·¶Àý£º±¾ÀýÊ¡ÂÔ´óÀ¨ºÅ¡£
<?php
if ($state==1)echo "¹þ¹þ" ;
?>
ÕâÀïÌرð×¢ÒâµÄÊÇ£¬ÅжÏÊÇ·ñÏàµÈÊÇ==¶ø²»ÊÇ=£¬ASP³ÌÐòÔ±¿ÉÄܳ£·¸Õâ¸ö´íÎó£¬= ÊǸ³Öµ¡£
·¶Àý£º±¾ÀýµÄÖ´Ðв¿·ÖÓÐÈýÐУ¬²»¿ÉÊ¡ÂÔ´óÀ¨ºÅ¡£
<?php
if ($state==1) {
echo "¹þ¹þ ;
echo "<br>" ;
}
?>
µÚÁ½ÖÖÊdzýÁË if Ö®Í⣬¼ÓÉÏÁË else µÄÌõ¼þ£¬¿É½âÊÍ³É "Èô·¢ÉúÁËijÊÂÔòÔõÑù´¦Àí£¬·ñÔò¸ÃÈçºÎ½â
¾ö"¡£Óï·¨ÈçÏÂ
if (expr) { statement1 } else { statement2 } ·¶Àý£ºÉÏÃæµÄÀý×ÓÀ´Ð޸ijɸüÍêÕûµÄ´¦Àí¡£ÆäÖеÄ
else ÓÉÓÚÖ»ÓÐÒ»ÐÐÖ´ÐеÄÖ¸ÁÒò´Ë²»ÓüÓÉÏ´óÀ¨ºÅ¡£
<?php
if ($state==1) {
echo "¹þ¹þ" ;
echo "<br>";
}
else{
echo "ºÇºÇ";
echo "<br>";
}
?>
µÚÈýÖÖ¾ÍÊǵݹéµÄ if..else Ñ»·£¬Í¨³£ÓÃÔÚ¶àÖÖ¾ö²ßÅжÏʱ¡£Ëü½«Êý¸ö if..else ÄÃÀ´ºÏ²¢ÔËÓô¦
Àí¡£
Ö±½Ó¿´ÏÂÃæµÄÀý×Ó
<?php
if ( $a > $b ) {
echo "a ±È b ´ó" ;
} elseif ( $a == $b ) {
echo "a µÈÓÚ b" ;
} else {
echo "a ±È b С" ;
}
?>
ÉÏÀýÖ»Óöþ²ãµÄ if..else Ñ»·£¬ÓÃÀ´±È½Ï a ºÍ b Á½¸ö±äÁ¿¡£Êµ¼ÊҪʹÓÃÕâÖֵݹé if..else Ñ»·Ê±£¬
ÇëСÐÄʹÓã¬ÒòΪ̫¶à²ãµÄÑ»·ÈÝÒ×ʹÉè¼ÆµÄÂß¼³öÎÊÌ⣬»òÕßÉÙ´òÁË´óÀ¨ºÅµÈ£¬¶¼»áÔì³É³ÌÐò
³öÏÖĪÃûÆäÃîµÄÎÊÌâ¡£
2¡¢ for Ñ»·¾Íµ¥´¿Ö»ÓÐÒ»ÖÖ£¬Ã»Óб仯£¬ËüµÄÓï·¨ÈçÏÂ
for (expr1; expr2; expr3) { statement }
ÆäÖÐµÄ expr1 ΪÌõ¼þµÄ³õʼֵ¡£expr2 ΪÅжϵ
Ïà¹ØÎĵµ£º
¡¶Head First
Éè¼Æģʽ¡·ÊDZ¾²»´íµÄ½²½âÉè¼ÆģʽµÄÊ飬²»ÏñF4дµÄÄÇô¿ÝÔӦ¸ÃËãÊDZȽÏÈÝÒ×Àí½âµÄºÃÊé¡£ÊéÖеÄÀý×Ó¶¼±È½ÏdzÏÔÒ׶®£¬²»¹ýÓÉÓÚÊÇÍâ¹úÀÐдµÄ£¬ËùÒÔÀý×Ó
µÄÏ°¹ß²»ÊǺܸ½ºÏÖйúÌØÉ«£¬¿ÉÄÜż¶û¿´ÆðÀ´ÓÐЩ±ðŤ£¬»¹ÓÐÓïÑÔÏ°¹ßÒ²²»ÊÇÖйú·ç¡£µ±È»¿´¹ýÕâ±¾ÊéÖ®ºó£¬Äã²ÅÄÜÉî¿ÌÀí½âÉè¼Æģʽµ½µ×ÄÜΪÄã½â¾öÄÄЩ
퉣 ......
/***************************by
garcon1986********************************/
<?php
//example1
$makefoo = true;
bar();
if($makefoo){
function foo(){
echo "doesn't exist.<br>";
}
}
if($makefoo)foo();
function bar(){
echo "exist<br>";
}
//example2
funct ......
/***************************by garcon1986**************************/
form.html
<html>
<head>
<title>Upload File</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST" action="uploader.php">
<label> ......
php¹Ø¼ü´Ê
phpÖÐÓÃÓÚÎļþ°üº¬µÄ¹Ø¼ü´ÊÓÐ:include¡¢include_once¡¢require¡¢require_once¡£Ò»°ãÀ´Ëµ£¬°ÑincludeºÍrequire·ÖÔÚÒ»×éÀ¶øinclude_onceºÍrequire_onceÊÇÒ»ÖָĽøÍêÉÆÐÎʽ¡£±¾ÎÄͨ¹ýÑо¿includeºÍrequireµÄÐÔÖÊ£¬¼æ¹Ëinclude_onceºÍrequire_once£¬»ñµÃphpÎļþ°üº¬µÄ»ù±¾ÖªÊ¶ºÍDZÔÚ ......