php define() º¯Êý¼°defined£¨£©º¯ÊýµÄÓ÷¨
The define() function defines a constant.
define()º¯ÊýµÄ×÷ÓÃÊÇ£º¶¨ÒåÒ»¸ö³£Á¿¡£
Constants are much like variables, except for the following differences:
³£Á¿[constant]Óë±äÁ¿[variable]ÓкܶàÏàËƵĵط½£¬Òò´Ë£¬ºÜÈÝÒ×»ìÏý£»ÏÂÃ棬ÎÒÃÇÁоÙһϳ£Á¿[constant]Óë±äÁ¿[variable]Ö®¼äµÄ²»Í¬µã£º
A constant's value cannot be changed after it is set
Ò»¸ö³£Á¿ÖµÔÚÖ¸¶¨Ö®ºó¾Í²»¿ÉÒÔ¸ü¸Ä£»
Constant names do not need a leading dollar sign ($)
ÉèÖó£Á¿Ê±£¬²»ÐèÒªÔÚÇ°Ãæ¼ÓÉÏ“$”·ûºÅ£»
Constants can be accessed regardless of scope
³£Á¿¿ÉÒÔ±»ËùÓз¶Î§µÄÓò·ÃÎÊ£»
Constant values can only be strings and numbers
³£Á¿µÄÖµÖ»ÄÜÊÇ“×Ö·û´®[string]”ºÍ“Êý×Ö[number]”£»
Syntax
Óï·¨
define(name,value,case_insensitive)
Parameter
²ÎÊýDescription
ÃèÊö
name
Required. Specifies the name of the constant
±ØÒª²ÎÊý¡£Ö¸¶¨³£Á¿µÄÃû³Æ
value
Required. Specifies the value of the constant
±ØÒª²ÎÊý¡£Ö¸¶¨³£Á¿µÄÖµ
case_insensitive
Optional. Specifies whether the constant name should be case-insensitive. If set to TRUE, the constant will be case-insensitive. Default is FALSE (case-sensitive)
¿ÉÑ¡²ÎÊý¡£Ö¸¶¨³£Á¿µÄÃû³ÆÊÇ·ñÊDz»Çø·Ö´óСдµÄ[case-insensitive]¡£Èç¹ûÉèÖÃΪTrue£¬Ôò²»Çø·Ö×Öĸ´óСд£»Èç¹ûÉèÖÃΪFalse£¬ÔòÇø·Ö×Öĸ´óСд¡£Ä¬ÈÏÖµÊÇ£ºFalse
Example 1
°¸Àý1
Define a case-sensitive constant:
Ö¸¶¨Ò»¸ö³£Á¿£¨Çø·Ö´óСд£©£º
<?phpdefine("GREETING","Hello you! How are you today?");echo constant("GREETING");?>
The output of the code above will be:
ÉÏÊö´úÂ뽫Êä³öÏÂÃæµÄ½á¹û£º
Hello you! How are you today?
Example 2
°¸Àý2
Define a case-insensitive constant:
Ö¸¶¨Ò»¸ö³£Á¿£¨²»Çø·Ö´óСд£©£º
<?phpdefine("GREETING","Hello you! How are you today?",TRUE);echo constant("greeting");?>
The output of the code above will be:
ÉÏÊö´úÂ뽫Êä³öÏÂÃæµÄ½á¹û£º
Hello you! How are you today?
The defined() function checks whether a constant exists.
defined()º¯ÊýµÄ×÷ÓÃÊÇ£º¼ì²éÒ»¸ö³£Á¿ÊÇ·ñ´æÔÚ¡£
Returns TRUE if the constant exists, or FALSE
Ïà¹ØÎĵµ£º
·ÖÒ³¹¦ÄܵÄʵÏÖÊÇÿÖÖWEB¿ª·¢ÓïÑÔ±ØÐëҪʵÏֵŦÄÜ¡£PHPÒ²ºÃ,JSPÒ²°Õ¡£ÎÒ×¼±¸ÓÃÁ½¸ö·½·¨À´²ûÊöPHP+MYSQLʵÏÖ·ÖÒ³µÄ¹¦ÄÜ¡£
Ò»¡¢·ÖÒ³³ÌÐòµÄÔÀí
·ÖÒ³³ÌÐòÓÐÁ½¸ö·Ç³£ÖØÒªµÄ²ÎÊý£ºÃ¿Ò³ÏÔʾ¼¸Ìõ¼Ç¼£¨$pagesize£©ºÍµ±Ç°Êǵڼ¸Ò³£¨$page£©¡£ÓÐÁËÕâÁ½¸ö²ÎÊý¾Í¿ÉÒԺܷ½±ãµÄд³ö·ÖÒ³³ÌÐò£¬ÎÒÃÇÒÔMySqlÊý¾Ý¿â×÷ΪÊý¾ÝÔ´£¬ ......
ÔÚPHP±à³ÌÖÐ, ÎÒÃǾ³£»áÓöµ½Ò»Ð©Ö±½Ó²úÉúÊä³öµÄº¯Êý, Èçpassthru(),readfile(), var_dump() µÈ. µ«ÓÐʱÎÒÃÇÏë°ÑÕâЩº¯ÊýµÄÊä³öµ¼Èëµ½ÎļþÖÐ,»òÕßÏȾ¹ý´¦ÀíÔÙÊä³ö, »òÕß°ÑÕâЩº¯ÊýµÄÊä³ö×÷Ϊ×Ö·û´®À´´¦Àí.
¡¡¡¡ÕâʱÎÒÃǾÍÒªÓõ½ Output Buffer(Êä³ö»º³å) º¯ÊýÁË.
´¦ÀíÊä³ö»º³åµÄº¯ÊýÖ÷ÒªÓÐÕâô¼¸¸ö:
ob_start() ¿ªÊ¼Ê ......
ÔÚPHPÖÐʹÓùýSESSIONµÄÅóÓÑ¿ÉÄÜ»áÅöµ½Õâôһ¸öÎÊÌ⣬ÔÚijЩ¿Í»§¶ËµçÄÔÉÏSESSION±äÁ¿²»ÄÜ¿çÒ³´«µÝ¡£ÕâÁîÎÒ¿àÄÕÁ˺ÃЩÈÕ×Ó£¬×îÖÕͨ¹ý²é×ÊÁÏ˼¿¼²¢½â¾öÁËÕâ¸öÎÊÌâ¡£ÎÒÈÏΪ£¬³öÏÖÕâ¸öÎÊÌâµÄÔÒòÓÐÒÔϼ¸µã£º
1¡¢¿Í»§¶Ë½ûÓÃÁËcookie
2¡¢ä¯ÀÀÆ÷³öÏÖÎÊÌ⣬ÔÝʱÎÞ·¨´æÈ¡cookie
3¡¢php.iniÖеÄsession.use_trans_sid = 0»òÕß±àÒë ......
http://www.oracle.com/technology/global/cn/pub/notes/technote_php_instant.html
Ϊ Linux ºÍ Windows °²×° PHP ºÍ Oracle 10g Instant Client
×÷ÕߣºChristopher Jones£¬¼×¹ÇÎĹ«Ë¾µÄ×Éѯ¼¼ÊõÈËÔ±
·¢²¼ÈÕÆÚ£º2004 Äê 12 ÔÂ
Oracle 10g Instant Client£¨Ãâ·ÑÏÂÔØ£©ÊÇPHP ÓëÔ¶³Ì Oracle Êý¾Ý¿âÁ¬½ÓµÄ×î¼òµ¥·½Ê½£¬Ëü ......