Re: [請益] 放置 include 的地方
include_once()
所指定的檔案被引入過了,那 include_once() 就不會再重複做一次引入的動作
確保不會重複引入相同檔案,而產生函數重複定義 (function redefinitions)
或者是變數重複給值 (value reassignments)。
※ 引述《cpqq (cpqq)》之銘言:
: 各位前輩,
: 我如果把 include 放在 php 檔最前面,沒有辦法引用 include 檔內的變數,
: 如果是把 include 放在 function 裡面就可以了,程式如下:
: <?php // not working 會出現錯誤
: include_once 'config/config.inc.php';
: function displayMenu(){
: echo '<div id="menu"><ul>';
: ...
: }
: ?>
: 如果是
: <?php //working 可正常輸出我所想要的
: function displayMenu(){
: include_once 'config/config.inc.php';
: echo '<div id="menu"><ul>';
: ...
: }
: ?>
: 請問為什麼會這樣呢?謝謝
--
Appleboy Blog: http://blog.Wu-Boy.com
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.25.236
※ 編輯: appleboy46 來自: 219.70.25.236 (03/18 15:17)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章