2014-05-18 3 views
0
$tpl = new Smarty(); 
$tpl->configLoad('compose.conf'); 
$config = $tpl->getConfigVars(); 
print_r($config); 

가, 내가 잘못하고있는 중이 야왜 인쇄 구성 배열이 빈 Array를 제공합니까?

Array() 

무엇입니까 반환? parse_ini_file의 매뉴얼에 따르면

[jquery] 
jquery = lib/jquery/jquery.js 

[jquery_validate] 
css=res/css/jquery.validate.css 
js=lib/jquery/jquery.validate.js 
X=jquery 


[bootstrap_css] 
main = lib/bootstrap/css/bootstrap.min.css 
theme = lib/ootstrap-theme.min.css 

[bootstrap_js] 
js = lib/bootstrap/js/bootstrap.min.js 
X=jquery 

[bootstrap] 
X=bootstrap_css,bootstrap_js 

[utils] 
utils=lib/utils/utils.js 
odo=lib/utils/utils.odo.js 
require=libutils/utils.require.js 
template=lib/utils/utils.template.js 
X=jquery 
+1

는'무엇을 포함 compose.conf' 않습니다 :)? – mbanzon

+0

config vars가 포함되어 있습니다 (편집 참조). – LNT

+0

오류 로그에 어떤 것이 있습니까?어쩌면'configLoad' 대신에'config_load'를 부를 것입니다. – mbanzon

답변

1

smarty_internal_config.php

if (!empty($sections)) { 

지금

if($sections=='*'){ 
     foreach ($_config_vars['sections'] as $key=>$value) { 
      if (isset($value['vars'])) { 
       $scope_ptr->config_vars[$key] = $value['vars']; 
      } 
     } 
    } else if (!empty($sections)) { 

와 동안으로이 문을 교체 한 Statment에 대한 검색 로딩 파일은 다음과 같이 사용합니다 :

$tpl = new Smarty(); 
$tpl->configLoad('compose.conf','*'); 
$config = $tpl->getConfigVars(); 
print_r($config); 

그게 전부는

1

compose.conf :

참고 : INI 파일에 대한 키로 사용할 수 없습니다 단어가 예약되어 있습니다. 이들은 다음과 같습니다 : null, yes, no, true, false, >>>on < < <, off, none. 값 null, off, nofalse""이됩니다. 값 on, yestrue"1"이됩니다. 문자 ?{}|&~![()^"은 키의 아무 곳에서나 사용되어서는 안되며 값에 특별한 의미가 있어야합니다.

우리가 파일 we get the following errorparse_ini_file (또는 parse_ini_string)을 실행하려고하면 :

경고 : 구문 오류,/tmp를/execpad-e67cf6f095ae 라인 7 에 알 수없는 예기치 않은 BOOL_TRUE/source-e67cf6f095ae on line 32

따라서 Smarty는 오류가 발생했습니다. 예약어를 사용하기 때문에 INI 파일을 구문 분석하십시오. 해결 방법은 ON의 이름을 다른 것으로 바꾸는 것입니다.

업데이트 :

스마티는이 기능을 사용하지 않는,하지만 파서를 복제합니다. smarty_internal_configfilelexer.php의 라인 # 313 "on"을 의미한다 : 당신의 유식 플러그인 디렉토리에서

if (!$this->smarty->config_booleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))) { 
//                         ^^ 
+1

X로 시도했지만 아직 작동하지 않습니다. – LNT

+0

@LNT'bootstrap_js' 아래에 여전히 하나가 남았습니다 : ON = jquery' – h2ooooooo

+1

죄송합니다. 실제 코드에서는 모두 제거되었지만 성공하지 못했습니다. – LNT

관련 문제