作者tao2tw (smile_ting)
看板PHP
標題[請益] 變數沒被定義 ci codeigniter
時間Sat Sep 15 00:04:58 2012
我的問題是這樣的,
我把我的陣列資料 define 在一個檔案 A.php
$a_gdocs = array(
"user" => "
[email protected]",
"passwd" =>
~~
);
然後在B檔案
XX function ()
{
require ("A.php");//gDocs Data
global $a_gdocs;
print_r($a_gdocs);
沒有顯示require錯誤,但是就是沒有正確的把 $a_gdocs載入
}
雖然說這個 XX function
也是在另外一個C.php 被呼叫的
實在是有點頭大......
煩請解惑一下 感恩
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 119.77.136.156
1F:推 liaosankai:你的A.php似乎是一些設定檔,你不應該用require方式 09/15 00:28
3F:推 Fantasywind:ci我記得不能自己require 09/15 00:35
4F:推 tkdmaf:要不寫在library,要不寫在helper,要不寫在model 09/15 00:44
5F:→ tao2tw:xx function 我寫在helper裡面 我是透過view 去呼叫的 09/15 09:20
6F:→ tkdmaf:如果你的變數資料是固定不變的,有用到global的必要? 09/15 09:54
7F:→ MOONRAKER:何不用config 一樣可以和主要config分開存放 分別載入 09/15 17:34
8F:→ MOONRAKER:$this->load->config('conf_gdocs'); 09/15 17:36
9F:→ MOONRAKER:陣列一樣可以寫成$config的元素存在config檔內 09/15 17:52
10F:→ tao2tw:現在我是丟到 config 去做處理了,目前運作正常 很感謝 09/15 20:06