PHPÀàµÄ×Ô¶¯¼ÓÔØ
ͨ³£ÎÒÃÇдһ¸öÀàÈçÏ£º
a.php
class A
{
public function __construct()
{
echo "hello world!";
}
}
page.php
require("a.php");
$a = new A();
ÎÒÃÇÊÇͨ¹ýÊÖ¹¤ÒýÓÃij¸öÀàµÄÎļþÀ´ÊµÏÖº¯Êý»òÕßÀàµÄ¼ÓÔØ
µ«Êǵ±ÏµÍ³±È½ÏÅÓ´ó£¬ÒÔ¼°ÕâЩÀàµÄÎļþºÜ¶àµÄʱºò£¬ÕâÖÖ·½Ê½¾ÍÏԵ÷dz£²»·½±ãÁË
ÓÚÊÇPHP5ÌṩÁËÒ»¸ö::auotload::µÄ·½·¨
ÎÒÃÇ¿Éͨ¹ý±àд¸Ã·½·¨À´×Ô¶¯¼ÓÔØµ±Ç°ÎļþÖÐʹÓõÄÀàÎļþ
page.php
function __autoload($classname)
{
$class_file = strtolower($classname).".php";
if (file_exists($class_file)){
require_once($class_file);
}
}
$a = new A();
ÕâÑù£¬µ±Ê¹ÓÃÀàAµÄʱºò£¬·¢ÏÖµ±Ç°ÎļþÖÐûÓж¨ÒåA£¬Ôò»áÖ´ÐÐautoloadº¯Êý£¬²¢¸ù¾Ý¸Ãº¯ÊýʵÏֵķ½Ê½£¬È¥¼ÓÔØ°üº¬AÀàµÄÎļþ
ͬʱ£¬ÎÒÃÇ¿ÉÒÔ²»Ê¹Óø÷½·¨£¬¶øÊÇʹÓÃÎÒÃÇ×Ô¶¨ÒåµÄ·½·¨À´¼ÓÔØÎļþ£¬ÕâÀï¾ÍÐèҪʹÓõ½º¯Êý
bool spl_autoload_register ( [callback $autoload_function] )
page.php
function my_own_loader($classname)
{
$class_file = strtolower($classname).".php";
if (file_exists($class_file)){
require_once($class_file);
}
}
spl_autoload_register("my_own_loader");
$a = new A();
ʵÏÖµÄÊÇͬÑùµÄ¹¦ÄÜ
×Ô¶¨ÒåµÄ¼ÓÔØº¯Êý»¹¿ÉÒÔÊÇÀàµÄ·½·¨
class Loader
{
public static function my_own_loader($classname)
{
$class_file = strtolower($classname).".php";
if (file_exists($class_file)){
require_once($class_file);
}
}
}
// ͨ¹ýÊý×éµÄÐÎʽ´«µÝÀàºÍ·½·¨µÄÃû³Æ
spl_autoload_register(array("my_own_loader","Loader"));
$a = new A();
Ïà¹ØÎĵµ£º
ËùÐèÈí¼þÔ´´úÂë°ü£º
httpd-2.2.4.tar.gz mysql-5.0.27.tar.gz php-5.2.1.tar.bz2
freetype-2.3.2.tar.gz gd-2.0.34.tar.gz jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.bz2 libxml2-2.6.24.tar.bz2 zlib-1.2.2.tar.gz
°²×°Ë³Ðò£ºapache -> mysql ......
Apache 2 and PHP Installation
The following notes are how I got Apache 2 and PHP 5 (or PHP 4) working together on Linux. These instructions also apply, mostly, for any UNIX-like system, especially other Linux distributions. If you have a recent Linux distribution (say since 2002), you already hav ......
±±¾©´óѧÈí¼þÓë΢µç×ÓѧԺ“¶à²ã´Î¡¢¶à·½Ïò¡¢¶àÁìÓò¡¢Ä£¿é»¯” µÄ¿ª·Åʽ¿Î³ÌÌåϵ£¬¾Êµ¼ù¼ìÑéÖ¤Ã÷£¬·Ç³£ÊÊÓÃÓÚÅàÑø“¶à²ã´Î¡¢ÊµÓÃÐÍ¡¢¸´ºÏ½»²æÐÍ¡¢¹ú¼Ê»¯”µÄÈí¼þÓë΢µç×ÓÈ˲š£ÎªÂú×ãÉç»áºÍÆóÒµ¶ÔÈ˲ŵÄÐèÇ󣬶ԸßÖÊÁ¿µÄ¼ÌÐø½ÌÓýÏîÄ¿µÄÐèÇ󣬱±¾©´óѧÈí¼þÓë΢µç×ÓѧԺ³ÉÁ¢Á˼ÌÐø½ÌÓýÖÐÐÄ£¬ÃæÏòÉ ......