PHPÂëÅ©½ø»¯Ê·2
1.ÊÇ·ñ¿ÉÒÔÔÚÀàµÄÍⲿ·ÃÎÊÒ»¸öÊôÐÔÊÇÓÉ·ÃÎÊÐÞÊηûÀ´È·¶¨µÄ¡£
2.´ÓÀàµÄÍⲿֱ½Ó·ÃÎÊÀàµÄÊôÐÔÊÇÔã¸âµÄÏë·¨¡£ÃæÏò¶ÔÏóµÄÒ»¸ö·½·¨¾ÍÊǹÄÀø·â×°¡£ÔÚPHPÖУ¬ÎÒÃÇÒ»°ãͨ¹ý__get()Óë__set()º¯ÊýÀ´ÊµÏÖ¶Ô
ÊôÐԵķÃÎÊ.Èç¹û²»Ö±½Ó·ÃÎÊÒ»¸öÀàµÄÊôÐÔ¶øÊDZàд·ÃÎʺ¯Êý£¬ÄÇô¿ÉÒÔͨ¹ýÒ»¶Î´úÂëÖ´ÐÐËùÓзÃÎÊ¡£×î³õµÄ·ÃÎʺ¯ÊýÈçÏÂËùʾ:
class classname {
public $attribute;
function __get($name) {
return $this->$name;
}
function __set($name, $value){
$this->$name = $value;
}
}
3.´Ë·ÃÎÊÆ÷º¯ÊýµÄÔÀí¾ÍÊÇÕâÑù£ºÖ»Ê¹ÓÃÒ»¶Î´úÂëÀ´·ÃÎÊÌض¨ÊôÐÔ¡£ÓÉÓÚÖ»ÓÐÒ»¸öÈë¿Ú£¬¾Í¿ÉÒÔ¶ÔÒª±£´æµÄÊý¾Ý½øÐмì²é£¬¿ÉÒÔÈ·±£±£´æµÄÊý
¾ÝÊÇÓÐÒâÒåµÄÊý¾Ý¡£ÀýÈç:
function _set ($name, $value) {
if( ($name == "attribute") && ($value >= 0) && ($value <= 100) ) {
$this->attribute = $value;
}
}
4.ͨ¹ýµ¥Ò»µÄ·ÃÎÊÈë¿Ú£¬¿ÉÒÔ·½±ãµØ¸Ä±äDZÔڵijÌÐòʵÏÖ¡£Èç¹ûÓÉÓÚijÖÖÔÒò£¬ÐèÒª¸Ä±äÊôÐÔ$attributeµÄ±£´æ·½Ê½£¬·ÃÎÊÆ÷º¯ÊýÔÊÐíÎÒÃÇÖ»
ÒªÐÞ¸ÄÒ»´¦´úÂ룬¾Í¿ÉÒÔÍê³É´Ë¹¤×÷¡£
5.__get(),__set(),__isset(),__unset().
Ò»°ãÀ´Ëµ£¬×ÜÊÇ°ÑÀàµÄÊôÐÔ¶¨ÒåΪprivate,ÕâÑù¸ü¸´ºÏÏÖʵÂß¼¡£
__get(),__set():ÓÃÀ´»ñÈ¡ºÍ¸³ÖµÆäÊôÐÔ.ËûÃDz»ÊÇĬÈÏ´æÔÚµÄ,¶øÊÇÎÒÃÇÊÖ¹¤Ìí¼Ó½øÈ¥µÄ¡£
__isset(),__unset():À´¼ì²éÊôÐÔºÍɾ³ýÊôÐÔ¡£
6.__get()Óë__set(),__isset()Óë__unset()µÄÒ»°ãÌí¼Ó·½·¨¡£
//__get()·½·¨ÓÃÀ´»ñȡ˽ÓÐÊôÐÔ.
private function __get($property_name) {
if (isset($this -> property_name)) {
return($this -> $property_name);
} else {
return(NULL);
}
}
//__set()·½·¨ÉèÖÃ˽ÓÐÊôÐÔ
private function __set($property_name,$value) {
$this -> $property_name = $value;
}
//__isset()·½·¨¿ÉÒÔÉèΪ˽ÓÐ
private function __isset($property_name) {
Ïà¹ØÎĵµ£º
<?
require ("config.php3");
?>
<?
if($submit)
{
//echo $action;
//if($action=='update') &nb ......
phpÉú³ÉËæ»úµÄº¯ÊýÓÐrand()£¬mt_rand()¡£ÕâÁ©º¯Êý¶ÔÓ¦µÄÖÖ×Óº¯Êýsrand(),mt_srand()¡£
ÔÚphp 4.2.0֮ǰÔÚµ÷ÓÃËæ»úº¯Êý֮ǰµÃÏÈÉèÖÃÖÖ×Óº¯Êý£¬²»È»Éú³ÉµÄÊý¶¼ÊÇΨһµÄ¡£
È磺
4.2.0°æ±¾Ö®Ç°£º
<?
srand((double)microtime()*1000000); //²úÉúËæ»úÖÖ×Óseed
$randval = rand(0,100); //ÔÚ0ºÍ100Ö®¼äÈ¡Ò»¸ ......
ÔÚPHPÀïµÃµ½Ç°ÌìºÍ×òÌìµÄÈÕÆڵĴúÂëÇ°ÌìÈ¥ÃæÊÔµÄʱºòÒ²ÊÇÕâÑù,²»¹ýÎÒµ±Ê±¼Ç²»ÆðÀ´ÁË.¾Í¼ÇµÃMYSQLÀïÃæµÄdate_sub(now(),'interval 1 day');date('Y/m/d h:i:s',mktime(date('h'), date('i'), date('s'), date('m') , date('d')+1, date('Y'))); -------------------------------------------------------------------------- ......
½ñÌìÓÖͻȻ·¢ÏÖÁËÒ»¸ö¼¼ÇÉ£¬¾ÍÊÇPHP¿ÉÒÔ´«Öµ¸øjs£¬ÈçºÎ×öÄØ£¿
ÔÀ´PHPµÄÔÀíÊÇÕâÑùµÄ£º
PHPµÄËùÓÐÓ¦ÓóÌÐò¶¼ÊÇͨ¹ýWEB·þÎñÆ÷(ÈçIIS»òApache)ºÍPHPÒýÇæ³ÌÐò½âÊÍÖ´ÐÐÍê³ÉµÄ£¬¹¤×÷¹ý³Ì£º
(1)µ±Óû§ÔÚä¯ÀÀÆ÷µØÖ·ÖÐÊäÈëÒª·ÃÎʵÄPHPÒ³ÃæÎļþÃû£¬È»ºó»Ø³µ¾Í»á´¥·¢Õâ¸öPHPÇëÇ󣬲¢½«ÇëÇó´«ËÍ»¯Ö§³ÖPHPµÄWEB·þÎñÆ÷¡£
(2)WEB·þÎñÆ ......