×ðÁú¿­Ê±

thinkphpÉèÖÃÎļþÐÞ¸Ä

ÔÚʹÓÃthinkphp¿ò¼Ü¿ª·¢phpÓ¦ÓóÌÐòʱ£¬¾­³£ÐèÒª¶ÔÉèÖÃÎļþ¾ÙÐÐÐÞ¸ÄÒÔÖª×ãÓªÒµÐèÇó¡£±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùÐÞ¸ÄthinkphpµÄÉèÖÃÎļþ¡£

ÕÒµ½ÉèÖÃÎļþ

ThinkPHPµÄÉèÖÃÎļþͨ³£´æ·ÅÔÚÏîÄ¿µÄ¸ùĿ¼ÏµÄapplicationĿ¼ÖеÄconfig.phpÎļþÖС£Ò²ÓпÉÄܱ£´ædatabase.phpµÈÆäËûÉèÖÃÎļþ£¬²»¹ýÕâЩÎļþµÄÃû³ÆºÍλÖÿÉÄÜ»áÒòСÎÒ˽¼Ò»ò¹«Ë¾¿ª·¢ÕßµÄÏ°¹ß¶øÓÐËù²î±ð¡£

·­¿ªÉèÖÃÎļþ

ͨ¹ý·­¿ª¸ÃÎļþ£¬ÎÒÃÇ¿ÉÒÔ¿´µ½ÆäÖаüÀ¨ÁË´ó×ÚµÄÉèÖÃÐÅÏ¢£¬ÕâЩÉèÖÃÐÅϢƾ֤²î±ðµÄ¹¦Ð§·ÖΪ²î±ðµÄÄ£¿é£¬ÈçÊý¾Ý¿â¡¢Â·ÓÉ¡¢»º´æ¡¢ÈÕÖ¾µÈ¡£

¹ØÓÚÖ¸¶¨µÄÉèÖÃÏ¿ÉÒÔƾ֤ÀÏÀýÕÒµ½¶ÔÓ¦µÄÉèÖÃÏî²¢ÐÞ¸ÄÆäÖµ¡£ºÃ±È£º

return [

    // Êý¾Ý¿âÉèÖÃ
    'database' => [
        'type'        => 'mysql',
        'hostname'    => 'localhost',
        'database'    => 'test',
        'username'    => 'root',
        'password'    => '123456',
        'hostport'    => '3306',
        'charset'     => 'utf8', 
        'prefix'      => '',
        'debug'       => true,
        'deploy'      => 0,
        'rw_separate' => false,
        'master_num'  => 1,
        'slave_no'    => '',
        'fields_strict' => true,
        'resultset_type' => 'array',
        'auto_timestamp' => false,
        'sql_explain' => false,
    ],

    // ·ÓÉÉèÖÃ
    'route' => [
        'default_controller'    => 'Index',
        'default_action'        => 'index',
        'default_module'        => 'index',
        'url_html_suffix'       => 'html',
        'url_common_param'      => true, 
        'url_route_on'          => true, 
        'route_complete_match'  => false,
        'url_route_must'        => false,
        'url_domain_deploy'     => false,
        'url_domain_root'       => '', 
        'url_convert'           => false, 
        'url_controller_layer'  => 'controller',
        'var_controller'        => 'c',
        'var_action'            => 'a',
    ],

    // »º´æÉèÖÃ
    'cache' => [
        'type'   => 'File',
        'expire' => 0,
        'prefix' => '',
        'path'   => '',
        'host'   => '',
        'port'   => '',
        'password' => '',
        'select' => 0,
        'persistent' => false,
        'timeout' => 0,
        'persistent_id' => '',
    ],

    // ÈÕÖ¾ÉèÖÃ
    'log' => [
        'type' => 'File',
        'path' => LOG_PATH,
        'level' => ['error'],
    ],

    // ÆäËûÉèÖÃ...
];

µÇ¼ºó¸´ÖÆ

ÀýÈ磬ÎÒÃÇÏ£Íû½«Êý¾Ý¿âÃÜÂë¸ÄΪ654321£¬Ö»ÐèÔÚ¶ÔÓ¦µÄÉèÖÃÏîÖÐÐ޸ģº

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

'database' => [ 
    'type'        => 'mysql',
    'hostname'    => 'localhost',
    'database'    => 'test',
    'username'    => 'root',
    'password'    => '654321', // ½«passwordÖµÐÞ¸ÄΪÐÂÃÜÂë
    'hostport'    => '3306',
    'charset'     => 'utf8', 
    'prefix'      => '',
    'debug'       => true,
    'deploy'      => 0,
    'rw_separate' => false,
    'master_num'  => 1,
    'slave_no'    => '',
    'fields_strict' => true,
    'resultset_type' => 'array',
    'auto_timestamp' => false,
    'sql_explain' => false,
],

µÇ¼ºó¸´ÖÆ

ÉúÑÄÐÞ¸Ä

ÐÞ¸ÄÍê±Ïºó£¬Ö±½ÓÉúÑļ´¿É¡£

²âÊÔÐÞ¸Ä

Ϊȷ±£ÐÞ¸ÄÉúЧ£¬ÎÒÃÇ¿ÉÒÔÔÚÓ¦ÓóÌÐòÖÐʵÑé¶ÁÈ¡Ð޸ĺóµÄÉèÖÃÖµ¡£ºÃ±È£¬ÔÚÒ»¸ö¿ØÖÆÆ÷ÖпÉÒÔʹÓÃÈçÏ´úÂë¶ÁÈ¡Êý¾Ý¿âÉèÖÃÎļþÖеÄÓû§ÃûºÍÃÜÂ룺

<?php
namespace appindexcontroller;

class Test
{
    public function index()
    {
        $config = config('database'); // »ñÈ¡Êý¾Ý¿âÉèÖÃÐÅÏ¢
        echo 'Óû§Ãû£º'. $config['username'] .'<br>';
        echo 'ÃÜÂ룺'. $config['password'] .'<br>';
    }
}

µÇ¼ºó¸´ÖÆ

È»ºóÔÚä¯ÀÀÆ÷Öлá¼û¸Ã¿ØÖÆÆ÷µÄÒªÁ죬¼´¿É¿´µ½Êä³öµÄÓû§ÃûºÍÃÜÂëÒѾ­±»ÐÞ¸ÄΪÐÂÖµ¡£

ͨ¹ýÐÞ¸ÄThinkPHPµÄÉèÖÃÎļþ£¬ÎÒÃÇ¿ÉÒÔ¿ìËٵص÷½âÓ¦ÓóÌÐòµÄÖÖÖÖÉèÖòÎÊý£¬ÒÔ±ã¸üºÃµØ˳Ӧ²î±ðµÄÓªÒµÐèÇó¡£ÔÚÏÖʵ¿ª·¢Àú³ÌÖУ¬ÎÒÃÇÓ¦¸Ãƾ֤ÏêϸÇéÐÎÑ¡ÔñºÏÊʵÄÉèÖòÎÊý¾ÙÐÐÐ޸ģ¬ÒÔ³ä·ÖÑéÕ¹¿ò¼ÜµÄÓÅÊÆ¡£

ÒÔÉϾÍÊÇthinkphpÉèÖÃÎļþÐ޸ĵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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