尊龙凯时人生就是博

thinkphp5ÔÚÄÇÀï½ç˵³£Á¿

thinkphp5ÊÇÒ»¿îÏÖ´ú»¯µÄphp¿ª·¢¿ò¼Ü £¬Ëü¾ßÓÐÓÅÑŵÄÓï·¨¡¢Ç¿Ê¢µÄ¹¦Ð§ºÍ±ã½ÝµÄ²Ù×÷¡£ÔÚʹÓÃthinkphp5¾ÙÐпª·¢Àú³ÌÖÐ £¬³£³ £»áÉæ¼°µ½³£Á¿µÄ½ç˵¡£±¾ÎĽ«»áÌÖÂÛthinkphp5ÔÚÄÇÀï½ç˵³£Á¿ÒÔ¼°³£Á¿µÄÏà¹Ø֪ʶ¡£

ÔÚthinkphp5ÖÐ £¬³£Á¿µÄ½ç˵ÓÐÁ½ÖÖ·½·¨£ºÒ»ÖÖÊÇÔÚconfigÉèÖÃÎļþÖнç˵ £¬ÁíÒ»ÖÖÊÇÔÚ´úÂëÖÐʹÓÃdefine()º¯Êý½ç˵¡£

ÔÚconfigÉèÖÃÎļþÖнç˵³£Á¿

ÔÚthinkphp5ÖÐ £¬ÎÒÃÇ¿ÉÒÔÔÚconfigĿ¼ÏÂÃæµÄÎļþÖнç˵³£Á¿¡£ÀýÈ磺config.phpÎļþ £¬½ç˵һ¸ö³£Á¿WEBSITE_NAME £¬´úÂëÈçÏ£º

return [
    'WEBSITE_NAME' => 'My Website',
];

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÎÒÃÇʹÓÃreturn·µ»ØÒ»¸öÊý×é £¬Êý×éµÄ¼üÃûÊdz£Á¿Ãû³Æ £¬ÖµÊdz£Á¿µÄÖµ¡£ÔÚ´úÂëÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ·½·¨Ê¹Óó£Á¿£º

echo config('WEBSITE_NAME');

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÎÒÃÇʹÓÃÁËconfigº¯ÊýÀ´»ñÈ¡³£Á¿µÄÖµ¡£Í¨¹ýʹÓÃÕâÖÖ·½·¨ £¬ÔÚÕû¸öÓ¦ÓóÌÐòÖпÉÒÔÀû±ãµØʹÓÃÕâ¸ö³£Á¿¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

ʹÓÃdefine()º¯Êý½ç˵³£Á¿

³ýÁËÔÚconfigÉèÖÃÎļþÖнç˵³£Á¿Ö®Íâ £¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃPHPÄÚÖú¯Êýdefine()À´½ç˵³£Á¿¡£ÀýÈ磺

// ÔÚÈ«¾Ö½ç˵³£Á¿
define('WEBSITE_NAME', 'My Website');

// ÔÚÀàÖнç˵³£Á¿
class MyClass {
    const WEBSITE_NAME = 'My Website';
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÎÒÃÇʹÓÃÁËdefine()º¯Êý»®·ÖÔÚÈ«¾ÖºÍÀàÖнç˵ÁËÒ»¸ö³£Á¿¡£ÔÚ´úÂëÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ·½·¨Ê¹Óó£Á¿£º

echo WEBSITE_NAME;
echo MyClass::WEBSITE_NAME;

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖÐ £¬ÎÒÃÇÖ±½ÓʹÓó£Á¿ÃûÀ´»ñÈ¡³£Á¿µÄÖµ¡£

×ܽ᣺

ÔÚthinkphp5ÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃconfigÉèÖÃÎļþºÍdefine()º¯ÊýÀ´½ç˵³£Á¿¡£ÎÞÂÛʹÓÃÄÄÖÖ·½·¨ £¬¶¼¿ÉÒÔÀû±ãµØÔÚÕû¸öÓ¦ÓóÌÐòÖÐʹÓó£Á¿¡£ÔÚÏÖʵ¿ª·¢ÖÐ £¬ÎÒÃÇÓ¦¸Ã×ñÊØPHPµÄ³£Á¿ÃüÃû¹æ·¶ £¬Ê¹Óôóд×ÖĸºÍÏ»®Ïß¡°_¡±ÌåÏÖµ¥´Ê¼äµÄÍÑÀë·û¡£Í¬Ê± £¬½ç˵³£Á¿Ö®Ç°Ó¦¸ÃÏȼì²é³£Á¿ÊÇ·ñÒѾ­±»½ç˵¹ý £¬ÒÔ×èÖ¹³£Á¿µÄÖظ´½ç˵¡£

ÒÔÉϾÍÊÇthinkphp5ÔÚÄÇÀï½ç˵³£Á¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ