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ÊÖ²áÉÏÌṩÁËÒÔÏÂһЩÖ÷ÒªµÄmysqlÊý¾Ý¿âµÄÖ§³Öº¯Êý£º
mysql_affected_rows -- È¡µÃǰһ´Î MySQL ²Ù×÷ËùÓ°ÏìµÄ¼Ç¼ÐÐÊý
mysql_change_user -- ¸Ä±ä»î¶¯Á¬½ÓÖеǼµÄÓû§
mysql_client_encoding -- ·µ»Ø×Ö·û¼¯µÄÃû³Æ
mysql_close -- ¹Ø±Õ MySQL Á¬½Ó
mysql_connect -- ´ò¿ªÒ»¸öµ½ MySQL ·þÎñÆ÷µÄÁ¬½Ó
mysql_c ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/02/03/1-10/
ÓëÆäËû±à³ÌÓïÑÔ²»Í¬µÄÊÇ£ºPHPµÄÊý¾ÝÀàÐͲ»ÊÇÓɳÌÐòÔ±ÔÚ¶¨Òå±äÁ¿µÄʱºò¾ö¶¨µÄ£¬¶øÊÇÓÉPHPÔÚ³ÌÐòÔËÐйý³ÌÖж¨Òå¡£
PHP¹²Ö§³Ö8ÖÖÊý¾ÝÀàÐÍ£ºÕûÐÍ£¨integer£©¡¢¸¡µãÐÍ£¨float£©¡¢×Ö·û´®ÐÍ£¨string£©ºÍ²¼¶ûÐÍ£¨Boolean£©ËÄÖÖ±êÁ¿ÀàÐÍ£¬Êý×飨array£©ºÍ¶ÔÏó£¨object£ ......
array getimagesize(string filename)
¸Ãº¯Êý·µ»ØÒ»¸öËÄÎÞËØµÄ¾ØÕ󡢸æËßÄãËù¸øÎļþÃûµÄͼÏñ³ß
´ç¡£¸ÃÎļþµÄ¸ñʽ±ØÐëÊÇGIF,jpeg»òPNGÖеÄÈÎÒ»ÖÖ¡£
Ôª
ËØ
ÃèÊö
0
¿í¶ÈµÄÏñËØÊý
1
¸ß
¶ÈµÄÏñËØÊý
2
ͼÏñµÄÀàÐÍ£¨GIF=1,JPG=2,PNG=3)
3
ÔÚ
IMG±ê¼ÇÖпÉÓõ ......
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 ......