Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

һЩ±»ºöÊ PHP º¯Êý

×ªÔØ×Ô£ºhttp://www.gracecode.com/archives/3013/
×÷ÕߣºÊÖÆø²»´í
ÕæµÄÊDz»Óò»ÖªµÀ£¬ÆäʵÎÒÃÇÊìϤµÄ PHP »¹ÓкܶàºÃ¶«Î÷ûÓз¢¾ò¡£¿´µ½ÕâÆªÎÄÕÂ
£¬µ±Ê±¾ÍÀá±¼Á˺ü¸»Ø£¬ÖصãÍÆ¼öÏ£¬Ë³±ãÎÒ×Ô¼ºÒ²×ö¸öÕûÀí¡£
sys_getloadavg()
Õâ¸öº¯Êý
·µ»Øµ±Ç°ÏµÍ³µÄ¸ºÔؾùÖµÐÅÏ¢
£¨µ±È» Windows ϲ»ÊÊÓã©£¬ÏêϸÎĵµ¿ÉÒÔ·­ÔÄ PH ......

php »ù´¡±Ê¼Ç class

/***************************by
garcon1986********************************/
<?php
//¼òµ¥Ê¾Àý
class SimpleClass
{
public $var = 'a default value';
public function displayVar(){
echo $this->var;
}
}
// create an object´´½¨Ò»¸ö¶ÔÏó
$A = new SimpleClass;
//µ÷Ó÷½·¨
$A -> displayVa ......

php »ù´¡±Ê¼Ç array

/***************************by
garcon1986********************************/
<?php
// simple assgin the values
$arr1 = array(12 => 10, 'sjg' => 'yaya');
echo $arr1[12].'<br>'; // 10
echo $arr1['sjg']."<br>"; //yaya
echo "wo ai ni !<p> ......

php »ù´¡±Ê¼Ç string

/***************************by
garcon1986********************************/
<?php
// example for strings, single quoted, double quoted
echo 'display a string!<br>';
echo ' this displays
a splitted
string<br>';
echo 'i\'ll be "back"<br>';
echo 'she said:"i ......

PHPÖеÄÅú´¦Àí£¨Ò»£©

ת×Ô£º http://www.phpsoho.com/article/php/200809/09-239.html
Èç¹û Web Ó¦ÓóÌÐòÖеÄÒ»¸öÌØÐÔÐèÒª³¬¹ý 1 Ãë»ò 2 Ãë²ÅÄÜÍê³É£¬ÄÇôӦ¸ÃÔõô°ì£¿ÐèҪijÖÖÀëÏß´¦Àí½â¾ö·½°¸¡£Ñ§Ï°¼¸ÖÖ¶Ô PHP Ó¦ÓóÌÐòÖг¤Ê±¼äÔËÐеÄ×÷Òµ½øÐÐÀëÏß·þÎñµÄ·½·¨¡£
´óÐ͵ÄÁ¬ËøµêÓÐÒ»¸ö´óÎÊÌ⡣ÿÌ죬ÔÚÿ¼ÒÉ̵ê»á·¢ÉúÊýǧ´Î½»Òס ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ