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

PHPÖÐ__autoload()º¯ÊýµÄʹÓÃ


ÎÒÃÇÖªµÀÔÚPHP4ÀïÃæ£¬µ±ÎÒÃÇʹÓÃÒ»¸öÀàµÄʱºò£¬±ØÐ뽫¸ÃÀàËùÒÔÎļþʹÓÃinclude»òrequire¼Ó½øÀ´£¬ÕâÑùÎÒÃǾͿÉÒÔʹÓÃÀàÁË¡£
¶ø¶ÔÓÚPHP5À´ËµÒ²¿ÉÒÔʹÓÃÔÚPHP4ÀïÃæµÄ·½Ê½£¬½«ÀàÎļþ°ü½øÀ´£¬µ«µ±ÓÐÁË__autoloadÖ®ºó£¬ÕâÖÖÇé¿ö¾Í¿ÉÒÔ¿¿±àд¹æÔòҲʵÏÖ¡£
ÒÔÏ´úÂ룺
<?php 
$obj_A = new clsA(); 
$obj_B = new clsB(); 
?> 
PHP4ÏÂÕýȷд·¨Îª£º
<?php 
//PHP4 д·¨£¬Ö®Ç°±ØÐë¼ÓÔØÀàÎļþ
include_once "cls/clsA.php"; 
include_once "cls/clsB.php"; 
$obj_A = new clsA(); 
$obj_B = new clsB(); 
?> 
´¦Àí¼ÓÔØ²½ÖèΪ£º 
1,¼ÓÔØÀàÎļþ¡£ 
2,ʵÀý»¯Àà¡£ 
PHP5ÏÂʹÓÃ__autoload()£¨×Ô¶¯¼ÓÔØ£©µÄÕýȷд·¨Îª£º 
<?php 
// PHP5 Used __autoload function 
$obj_A = new clsA(); 
$obj_B = new clsB(); 
function __autoload($className){ 
include_once "cls/$className.php"; 

?> 
´¦Àí¼ÓÔØ²½ÖèΪ£¨Ê¹ÓÃautoloadº¯Êý£©£º 
1,´´½¨¶ÔÏó£¨Î±ÊµÀý£© 
2,µ÷ÓÃ__autoloadº¯Êý£¬½«Î±ÊµÀýµÄÀàÃû´«Èë 
3,ʹÓÃ__autoloadº¯ÊýÖУ¬Ô¤ÏÈдºÃµÄ¼ÓÔØ¹æÔò½øÐмÓÔØÀàÎļþ 
4,ʵÀý»¯¶ÔÏó£¨ÕæÊµÊµÀý£© 
Òò´Ë£¬ÎÒÃÇ¿ÉÒÔ¿´³ö£¬¶ÔÓÚPHP5µÄautoloadº¯Êý£¬±ØÐë¸ø¶¨¹æÔò£¬·ñÔòÒ»µãÓÃûÓС£ 
¶ÔÓÚPHP5µÄ__autoloadº¯ÊýµÄʹÓÃʱÐèҪעÒâ»òÍê³ÉÈçÏÂÊÂÇé¡£ 
1,__autoloadº¯ÊýÊÇÓÃÔÚÀàÍâÃæ£¬¶ø²»ÊÇÔÚÀàÀïÃæµÄº¯Êý¡££¨__autoloadÒ²ÊDZ»PHP5±£»¤µÄ¹Ø¼ü×ÖÖ®Ò»£© 
2,Íê³É¶Ô__autoloadº¯Êý¼ÓÔØ¹æÔòµÄ±àÂë¡£ 
ÈçÉÏ£¬µ±ÖªµÀAÊÇÔÚclsĿ¼ÖУ¬¶øBÊÇÔÚcls/clsĿ¼ÖС£Ôò±àд__autoload¼ÓÔØ¹æÔò¾ÍÊDZØÒªµÄ¡£
<?php 
// PHP5 Used __autoload function 
$obj_A = new clsA(); // in "cls" directory! 
$obj_B = new clsB(); // in "cls/cls" directory! 
function __autoload($className){ 
if(strtolowwer($className) == "clsb"){ 
require_once "cls/cls/$className.php"; 
}else{ 
include_once "cls/$className.php"; 


?> 
×ܽ᣺Òò´Ë£¬¶Ô


Ïà¹ØÎĵµ£º

PHPʵÏÖͼƬÉÏ´«

#################################
##########BY:Moskey.Tong#########
###########2009-11-15############
#########*×ªÔØÇë×¢Ã÷*############
#################################
×ܽáÒ»ÏÂÕâ¸öÐÇÆÚÌìPHPÉÏ´«Í¼Æ¬¡£
ÉÏ´«Í¼Æ¬Ô­Àí£ºÊ×ÏÈÅжÏÎļþÀàÐÍÊÇ·ñΪͼƬ¸ñʽ£¬ÈôÊÇÔòÉÏ´«Îļþ£¬È»ºóÖØÃüÃûÎļþ£¨Ò»°ã¶¼ÊDZÜÃâÉ ......

PHPÖÐsubstr()º¯ÊýµÄʵÀýÏê½â

Ô­ÐÍ£ºstring substr ( string $string , int $start [, int $length ] )£¬Ëü¿ÉÒÔÓÃÓÚÔÚÒ»¸ö½Ï³¤µÄ×Ö·û´®ÖвéÕÒÆ¥ÅäµÄ×Ö·û´®»ò×Ö·û¡£$stringΪËùÒª´¦ÀíµÄ×Ö·û´®£¬$startΪ¿ªÊ¼Ñ¡È¡µÄλÖã¬$lengthΪҪѡȡµÄ³¤¶È(µ±ËüÊǸºÊýʱΪ¸ºÊýʱ±íʾÓÒÆðÊýÆðµÄλÖÃ)¡£
Àý£º
<?php
$rest1 = substr("abcdef", 0, 0); // returns ......

PHP³õѧÕßѧϰʵÀý

.$dbhost = 'localhost';  
$dbuser = 'root'; //ÄãµÄmysqlÓû§Ãû  
$dbpass = '123456'; //ÄãµÄmysqlÃÜÂë  
$dbname = 'data'; //ÄãµÄmysql¿âÃû  
//Á¬½Ó±¾µØÊý¾Ý¿â
$GLOBALS["conn"] = mysql_connect($dbhost,$dbuser,$dbpass);  
//´ò¿ªÊý¾Ý¿â
mysql_select ......

php mysql»Ø¹öʾÀý

Ê×ÏÈ£¬½¨InnoDBÀàÐÍµÄ±í£¬²ÅÄÜÖ§³ÖÊÂÎñ
$handler = mysql_connect('localhost', '', '');
mysql_select_db('test');
mysql_query('SET AUTOCOMMIT=0'); // ÉèÖÃΪ²»×Ô¶¯Ìá½»²éѯ
mysql_query('START TRANSACTION'); // ¿ªÊ¼²éѯ£¬ÕâÀïÒ²¿ÉÒÔʹÓÃBEGIN
mysql_query("INSERT INTO users VALUES ('ccc')");
mysql_query( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ