phpÖÐµÄ Àà³£Á¿ Class Constants
It is possible to define constant values on a per-class basis remaining the same and unchangeable.
Constants differ from normal variables in that you don't use the $ symbol to declare or use them. Like static members, constant values cannot be accessed from an instance of the object (using $object::constant).
˵Ã÷£º const ³£Á¿ ²»Óà $ ·ûºÅ
const ²»¼Ó¹Ø¼ü×Ö private ÐÞÊÎ //Like static members,
²»ÄÜͨ¹ý ¶ÔÏó·ÃÎÊ¡£ Ö»ÄÜͨ¹ýclass·ÃÎÊ
Àý×Ó 19-15. Defining and using a constant
<?php
class MyClass
{
const constant = 'constant value';
function showConstant() {
echo self::constant . "\n";
}
}
echo MyClass::constant . "\n";
$class = new MyClass();
$class->showConstant();
// echo $class::constant; is not allowed
?>
Ïà¹ØÎĵµ£º
±¾ÕÂ×ÅÖØ½²ÊöPHPÊý¾Ý¿â³éÏó²ãÓëÊý¾Ý¿â³éÏóÀà¡£
Ŀǰ£¬ÔÚPHPµÄÍøÕ¾¼°ÖÚ¶àÊé¼®ÖУ¬ºÜÉÙ½²µ½Êý¾Ý¿â³éÏó²ã£¬ ÓеÄPHP¿ª·¢ÕßËäÈ»ÒÑ×öÁ˼¸Ä꿪·¢¹¤×÷£¬µ«ËƺõҲûÓÐÒâʶµ½ËüµÄ ´æÔÚ¡£
ºÜ¶àÈ˲¢²»Àí½âÊý¾Ý³éÏóµÄÖØÒªÐÔ£¬Ò²²» Á˽âmysql»òmysqliÀ© Õ¹ÓëPDOµÄÇø±ð£¬PDOÓëADODBÓÖÓÐÊ²Ã´Çø±ð¡£
ÔÚ±¾ÕÂÖн«½²ÊöÒÔÏÂÄÚÈÝ£¬Í¨¹ýѧϰ£ ......
8 ·ÃÎÊÀàÐÍ
ÀàÐ͵ķÃÎÊÐÞÊηûÔÊÐí¿ª·¢ÈËÔ±¶ÔÀà³ÉÔ±µÄ·ÃÎʽøÐÐÏÞÖÆ£¬ÕâÊÇPHP5 µÄÐÂÌØÐÔ£¬µ«È´ÊÇOOPÓïÑÔµÄÒ»¸öºÃµÄÌØÐÔ¡£¶øÇÒ´ó¶àÊýOOP ÓïÑÔ¶¼ÒÑÖ§³Ö´ËÌØÐÔ¡£PHP5 Ö§³ÖÈçÏÂ3 ÖÖ·ÃÎÊÐÞÊηû£º
public(¹«Óеġ¢Ä¬ÈϵÄ)£¬private(˽ÓеÄ)ºÍprotected(Êܱ£»¤µÄ)ÈýÖÖ¡£
public ¹«ÓÐÐÞÊηû£¬ÀàÖеijÉÔ±½«Ã»ÓзÃÎÊÏÞÖÆ£¬ËùÓеÄÍⲿ ......
1:·ÅÁË6¸öÎļþÔÚcÅÌÏÂ(php5ts.dll,libmysql.dll ,php_gd2.dll,php_mysql.dll,php_mbstring.dll ),Ò»¸öÔÚwindowsÏÂ,ÁíÎå¸öÔÚwindows/system32ÏÂ
2:ÅäÖÃÁËpath
3:ÃüÁî:httpd.exe -w -n "Apache2" -k start À´²é¿´ÊÇÄÄÒ»ÐеĴíÎóÐÅÏ¢.
×ܽá:µ½ÏÖÔÚΪֹ,ÕûÁËÒ»Ìì,×°ÁËÈý´ÎϵͳµÄÂé·³ÖÕÓÚÇ×ÉíÖ¤Ã÷ÁË,
Õâ¸ö×ï¿ý»öÊײúÉúµÄÔÒò ......
php±àÒëgd³ö´í!(Òѽâ¾ö)
ÔÚ32λubuntu9.04ÉϱàÒëphp5.2.12,µ½gdʱmake³ö´í:
ext/gd/libgd/.libs/gd_png.o: In function
`php_gd_gdImageCreatefromPngCtx':
/home/test/php-5.2.12/ext/gd/libgd/gd_png.c:142: undefined reference to
`png_check_sig'
collect2: ld returned 1 exit status
make: *** [sapi/cli/p ......