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();
Ïà¹ØÎĵµ£º
ÎÞÂÛÄÄÖÖÓïÑÔ£¬×Ö·û´®²Ù×÷¶¼ÊÇÒ»¸öÖØÒªµÄ»ù´¡£¬ÍùÍùÊǼòµ¥¶øÖØÒª¡£ÕýÏñÈË˵»°Ò»Ñù£¬Ò»°ãÓÐÐÎÌ壨ͼÐνçÃæ£©£¬ÓÐÓïÑÔ£¨print ×Ö·û´®£¿£©£¬ÏÔÈ»×Ö·û´®ÄܽâÊ͸ü¶àµÄ¶«Î÷¡£PHPÌṩÁË´óÁ¿µÄ×Ö·û´®²Ù×÷º¯Êý£¬¹¦ÄÜÇ¿´ó£¬Ê¹ÓÃÒ²±È½Ï¼òµ¥£¬ÏêϸÇë²Î¿´ http://cn2.php.net/manual/zh/ref.strings.php . ÒÔϽ«¼òµ¥µÄ½²ÊöËüµÄ¹¦ÄܺÍÌØÐ ......
php evalº¯ÊýÓ÷¨----PHPÖÐeval()º¯ÊýС¼¼ÇÉ
eval
½«Öµ´úÈë×Ö·û´®Ö®ÖС£
Óï·¨: void eval(string code_str);
´«»ØÖµ: ÎÞ
º¯Ê½ÖÖÀà: Êý¾Ý´¦Àí
ÄÚÈÝ˵Ã÷
±¾º¯Ê½¿É½«×Ö·û´®Ö®ÖеıäÁ¿Öµ´úÈ룬ͨ³£ÓÃÔÚ´¦ÀíÊý¾Ý¿âµÄÊý¾ÝÉÏ¡£²ÎÊý code_str ΪÓû´¦ÀíµÄ×Ö·û´®¡£ÖµµÃ×¢ÒâµÄÊÇ´ý´¦ÀíµÄ×Ö·û´®Òª·ûºÏ PHP µÄ×Ö·û´®¸ñʽ£¬Í¬Ê±ÔÚ½ ......
I’ve just updated Aptana Studio from 1.5 to 2.0 only to find out that the spectacular Aptana PHP plugin is not longer supported and its installation has been removed from the Install Additional Features view. However, with some tricks we can still install the old Aptana 1.5.1 in order to use i ......
<?php
/* Åжϳ£Á¿ÊÇ·ñ´æÔÚ*/
if (defined('MYCONSTANT')) {
echo MYCONSTANT;
}
//ÅжϱäÁ¿ÊÇ·ñ´æÔÚ
if (isset($myvar)) {
echo "´æÔÚ±äÁ¿$myvar.";
}
//ÅжϺ¯ÊýÊÇ·ñ´æÔÚ
if (function_exists('imap_open')) {
echo "´æÔÚº¯Êýimag_open\n";
} else {
echo "º¯Êýimag_open²»´æÔÚ\n";
}
//ÅжÏÀàÊÇ·ñ ......