php Ä£°åд·¨
<?php
/* @author: zhuyubing@gmail.com */
class Template{
var $code;
function Template($template){
$this->code = implode('', @file($template));
}
function assign($name,$var=null){
if(is_string($name) && is_string($var)){
$this->code = str_replace('{'.$name.'}', $var, $this->code);
} else if(is_array($var)){
list($this->code,$tmp,$end)=explode('<!--'.$name.'-->',$this->code);
while(list(,$v)=each($var)){
$t=$tmp;$k2=$v2='';
while(list($k2, $v2) = each($v)){
$t = str_replace('{'.$k2.'}', $v2,$t);
}
$this->code .= $t;
}
$this->code .= $end;
} else {
while (list ($k2, $v2) = each($name)){
$this->code = str_replace('{'.$k2.'}', $v2, $this->code);
}
}
}
function display(){
echo $this->code;
}
}
?>
×î¼òµ¥µÄhello_world
×¼±¸Ò»¸öphpÄ£°æÎļþhello_world.html
<html>
<head>
<meta http-equiv="Content-Type" c />
<title>{title}</title>
</head>
<body>
<h1>{title
Ïà¹ØÎĵµ£º
¡¶Head First
Éè¼ÆÄ£Ê½¡·ÊDZ¾²»´íµÄ½²½âÉè¼ÆÄ£Ê½µÄÊ飬²»ÏñF4дµÄÄÇô¿ÝÔӦ¸ÃËãÊDZȽÏÈÝÒ×Àí½âµÄºÃÊé¡£ÊéÖеÄÀý×Ó¶¼±È½ÏdzÏÔÒ×¶®£¬²»¹ýÓÉÓÚÊÇÍâ¹úÀÐдµÄ£¬ËùÒÔÀý×Ó
µÄϰ¹ß²»ÊǺܸ½ºÏÖйúÌØÉ«£¬¿ÉÄÜż¶û¿´ÆðÀ´ÓÐЩ±ðŤ£¬»¹ÓÐÓïÑÔϰ¹ßÒ²²»ÊÇÖйú·ç¡£µ±È»¿´¹ýÕâ±¾ÊéÖ®ºó£¬Äã²ÅÄÜÉî¿ÌÀí½âÉè¼ÆÄ£Ê½µ½µ×ÄÜΪÄã½â¾öÄÄЩ
퉣 ......
/***************************by
garcon1986********************************/
<?php
// variable name is sensitive
$var = "sjg";
$Var = "wl";
echo $var.' loves '.$Var.'<br>';
echo "$var, $Var<p>";
//naming conventions for variables
//$4site = 'not y ......
/***************************by
garcon1986********************************/
<?php
// boolean integer float example
$action = false;
if($action == "show version"){
echo "the version is 123".'<br>';
}else if($action == false){
echo "action is false".'< ......
/***************************by garcon1986**************************/
form.html
<html>
<head>
<title>Upload File</title>
</head>
<body>
<form enctype="multipart/form-data" method="POST" action="uploader.php">
<label> ......
1.php Êý¾ÝÀàÐÍ£º¸¡µãÐÍ,×Ö·û´®,ÕûÐÎ,Âß¼ÐÍ
2.$a="test"; print($a); ÔÚphp.ini ÖÐÉèÖÃerror_reporting=E_ALL ¾¯¸æ×´Ì¬Ê±£¬»áÓÐÌáʾ¡£´ËÓÃÓÚ²âÊÔ䶨ÒåµÄ±äÁ¿¡£¿ÉÒÔʹÓÃisset()¼ì²â±äÁ¿ÊÇ·ñ´æÔÚ,unsetÇå³ý±äÁ¿()£¬³£Á¿¶¨Òådefine("a","test");¶¨ÒåµÄ³£Á¿¾ßÓÐÈ«¾Ö×÷Óá£define ÎÞ·¨¶¨Òå¶ÔÏóµÄÊý¾Ý½á¹¹£¬²»¹ý¿ÉÒÔÏÈ´æ´¢±äÁ¿ ......