Re: [請益] 程式觀念問題 ? (include)
※ 引述《bojack (Bojack)》之銘言:
43
: 是用 define 來定義路徑嗎?如果是的話,是不是每一頁都要再 include 一個有關
: define 的檔案呢?
用 define 應該可以說是最好的解法。
例如:
=======================================================================
/home/www/public_html/config.php
------------------------------------------------------------------
define('ROOT_PATH' , '/home/www/public_html');
define('LIB_PATH' , '/home/www/public_html/lib');
define('DB_LIB' , LIB_PATH.'/db.php');
define('CONNECT_LIB' , LIB_PATH.'/connect.php');
...
=======================================================================
接下來每個程式只要用 include_once 包這支 config.php ,
就可以用 require_once 跟設定好的 macro 呼叫各個 lib 。
--
Leo [joehorn]:~> make love
make: don't know how to make love. Stop
Leo [joehorn]:~> why?
why?: No match.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.18.56.221
推
05/04 07:44, , 1F
05/04 07:44, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章