PHPÀàʵÀý½Ì³Ì£¨Ê®Ò»£©£ºÀàÖÐthis¹Ø¼ü×Ö
PHP5ÖÐΪ½â¾ö±äÁ¿µÄÃüÃû³åÍ»ºÍ²»È·¶¨ÐÔÎÊÌ⣬ÒýÈë¹Ø¼ü×Ö“$this”´ú±íÆäËùÔÚµ±Ç°¶ÔÏó¡£
$thisÔÚ¹¹Ô캯ÊýÖÐÖ¸¸Ã¹¹Ô캯ÊýËù´´½¨µÄжÔÏó¡£
ÔÚÀàÖÐʹÓõ±Ç°¶ÔÏóµÄÊôÐԺͷ½·¨£¬±ØÐëʹÓÃ$this->È¡Öµ¡£
·½·¨Äڵľֲ¿±äÁ¿£¬²»ÊôÓÚ¶ÔÏ󣬲»Ê¹ÓÃ$this¹Ø¼ü×ÖÈ¡Öµ¡£
¾Ö²¿±äÁ¿ºÍÈ«¾Ö±äÁ¿Óë $this ¹Ø¼ü×Ö,ʹÓõ±Ç°¶ÔÏóµÄÊôÐÔ±ØÐëʹÓÃ$this¹Ø¼ü×Ö¡£¾Ö²¿±äÁ¿µÄÖ»ÔÚµ±Ç°¶ÔÏóµÄ·½·¨ÄÚÓÐЧ£¬ËùÒÔÖ±½ÓʹÓá£
×¢Ò⣺¾Ö²¿±äÁ¿ºÍÊôÐÔ¿ÉÒÔͬÃû£¬µ«Ó÷¨²»Ò»Ñù¡£ÔÚʹÓÃÖУ¬Òª¾¡Á¿±ÜÃâÕâÑùʹÓã¬ÒÔÃâ»ìÏý¡£
<?php
class A
{
private $a = 99;
//ÕâÀïдһ¸ö´òÓ¡²ÎÊýµÄ·½·¨
public function printInt($a) {
echo "\$aÊÇ´«µÝµÄ²ÎÊý $a ";
echo "<br />";
echo "\$this->a ÊÇÊôÐÔ $this->a";
}
}
$a = new A(); //ÕâÀïµÄ$a¿É²»ÊÇÀàÖеÄÈκαäÁ¿
$a->printInt(88);
?>
ÓÃ$thisµ÷ÓöÔÏóÖеÄÆäËü·½·¨
<?php
class Math
{
//Á½¸öÊýÖµ±È½Ï´óС
public function Max($a, $b) {
return $a > $b ? $a : $b;
}
//Èý¸öÊýÖµ±È½Ï´óС
public function Max3($a, $b, $c) {
$a = $this->Max($a, $b); //µ÷ÓÃÀàÖеÄÆäËü·½·¨
return $this->Max($a, $c);
}
}
$math = new Math();
echo "×î´óÖµÊÇ " . $math->Max3(99, 100, 88);
?>
ʹÓÃ$thisµ÷Óù¹Ô캯Êý
µ÷Óù¹Ô캯ÊýºÍÎö¹¹º¯ÊýµÄ·½·¨Ò»Ö¡£
<?php
class A
{
private $a = 0;
public function __construct() {
$this->a = $this->a + 1;
}
public function doSomeThing() {
$this->__construct();
return $this->a;
}
}
$a = new A(); // ÕâÀïµÄ$a ¿É²»ÊÇÀàÖеÄÈκÎÒ»¸ö±äÁ¿ÁË
echo "ÏÖÔÚ \$a µÄÖµÊÇ" . $a->doSomeThing();
?>
$this µ½µ×Ö¸µÄʲô£¿
$this ¾ÍÊÇÖ¸µ±Ç°¶ÔÏó£¬ÎÒÃÇÉõÖÁ¿ÉÒÔ·µ»ØÕâ¸ö¶ÔÏóʹÓà $this¡£
<?php
class A
{
public function getASelf() {
return $this;
}
public function __toString() {
return "ÕâÊÇÀàAµÄʵÀý";
}
}
$a = new A(); //´´½¨AµÄʵÀý
$b = $a->getASelf(); //µ÷Ó÷½·¨·µ»Øµ±Ç°ÊµÀý
echo $a; //´òÓ¡¶ÔÏó»áµ÷ÓÃËüµÄ__toString·½·¨
?>
ͨ¹ý $this ´«µÝ¶ÔÏó
ÔÚÕâ¸öÀý×ÓÖÐ,ÎÒÃÇдһ¸ö¸ù¾Ý²»Í¬µÄÄêÁä·¢²»Í¬¹¤×ʵÄÀà¡£ÎÒÃÇÉè
Ïà¹ØÎĵµ£º
ÈÎÎñÐèÇó£ºÒ»¸ö»áÒéͶ¸åϵͳ£¬ÔÚ×÷ÕßÌá½»ÂÛÎÄժҪʱ×Ô¶¯Ïò×÷Õß·¢ËÍÒ»·âÈ·ÈÏÓʼþ¡£
(×¢£ºÍ¶¸åϵͳʹÓõÄÊÇmyreview
)
×Ðϸ¿¼ÂÇһϣ¬Õâ¸öÈÎÎñ¿ÉÒÔÓÐÒÔϼ¸ÖÖ·½Ê½Íê³É£º
ÔÚ·þÎñÆ÷ÉÏÅäÖÃsendmail·þÎñ£¬Ê¹ÓÃphpÖеĵÄmailº¯Êý·¢ËÍÓʼþ£»
ÔÚ·þÎñÆ÷ÉÏ°²×°mutt + msmtp£¬»òÕßÔÚ·þÎñÆ÷ÉÏ°²×°ÆäËüµÄsmtp¿Í»§¶Ë³ÌÐò£¬Ê¹ÓÃsmtp¿Í» ......
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
php´úÂë:
<?php
class ChineseSpell {
/**
* @var array $chineseSpellList Æ´Òô±àÂë¶ÔÓ¦±í
* @access private
*/
private $chineseSpellList = array(
'a'=>-20319,
'ai'=>-20317,
&nbs ......
0¡¢Óõ¥ÒýºÅ´úÌæË«ÒýºÅÀ´°üº¬×Ö·û´®£¬ÕâÑù×ö»á¸ü¿ìһЩ¡£ÒòΪPHP»áÔÚË«ÒýºÅ°üΧµÄ×Ö·û´®ÖÐËÑÑ°±äÁ¿£¬µ¥ÒýºÅÔò²»»á£¬×¢Ò⣺ֻÓÐechoÄÜÕâô×ö£¬ËüÊÇÒ»ÖÖ¿ÉÒ԰Ѷà¸ö×Ö·û´®µ±×÷²ÎÊýµÄ“º¯Êý”£¨Òë×¢£ºPHPÊÖ²áÖÐ˵echoÊÇÓïÑԽṹ£¬²»ÊÇÕæÕýµÄº¯Êý£¬¹Ê°Ñº¯Êý¼ÓÉÏÁËË«ÒýºÅ£©¡£
1¡¢Èç¹ûÄܽ«ÀàµÄ·½·¨¶¨Òå³Éstatic£¬¾Í¾¡ ......
http://php.net/manual/en/reserved.variables.httprawpostdata.php
http://www.cnblogs.com/mustardpeanut/archive/2009/06/15/1503395.html
http://blog.csdn.net/letianok/archive/2009/02/27/3941731.aspx
http://www.woria.cn/blog/read.php/596.htm ......