2012-06-29 2 views
1

매개 변수에 따라 변경되는 3 세트의 이미지를 출력하는 사용자 지정 노드를 구축 중입니다. mooFoo() 함수에 전달됩니다. 그러나 나는 "구문 분석 오류 : 구문 오류, 예기치 않은 T_GLOBAL"오류 및 그 매우 설명 형, 아무도 어쩌면 나에게 잘못 갈 수있는 것처럼 고개를 끄덕를 수 있어요, 나는 아무것도 찾지 않고 구글을 통해 스캔을 했어. 메가 도움이. 내 코드는 ... 아래와 같습니다PHP/Drupal 7 오류 구문 분석 오류 : 예기치 않은 구문 오류 T_GLOBAL in (C ......)

나는 곳의 borking 그래서 그게 생각 해달라고 내가 그러나 HTML에서 mooFoo()를 호출 한 방법에서 화면에 인쇄 할 수 없습니다 내 머리의 맨 오프
<?php 

$rooPath = 'http://localhost/'; 

//path from application root 
$relPath = 'trl/sites/default/files/'; 

$labTrl = 'TRL'; 
$dClass = 'ovinline'; 

//DEV 
$imgPathRed = 'redNodePng6160.png'; 
$imgPathAmb = 'amberNodePng6160.png'; 
$imgPathGre = 'greenNodePng6160.png'; 

function mooFoo($img){ 

$img2 = $img; 

switch($img2){ 
case 1: 
     $fullPath = global $rooPath . global $relPath . global $imgPathRed; 
     break; 
case 2: 
     $fullPath = global $rooPath . global $relPath . global $imgPathAmber; 
     break; 
case 3: 
     $fullPath = global $rooPath . global $relPath . global $imgPathGreen; 
     break;  
} 
return $fullPath; 
} 

?> 

    <div class="<?php echo $dClass?>"> 
     <div class="field-label"><?php echo $labTrl?> 1:&nbsp;</div> 
      <div class="field-items"> 
       <div class="field-item even"> 
        <img typeof="foaf:Image" src="<?php echo mooFoo(2)?>" width="61" height="60" alt="" /> 
       </div> 
      </div> 
    </div> 

저는 글로벌을 사용하려고하는 방식과 관련 있다고 가정하고 있지만, 그럴 수는 없습니다. 누군가가 나를 도울 수 있다면 크게 감사하겠습니다.

많은 감사

피터

답변

1

글로벌 물건을 좋아하세요 : 당신이 그것을 사용하는 것처럼

function mooFoo($img){ 
    global $rooPath, $relPath, $imgPathAmber, $imgPathGreen, $imgPathRed; 
// ... more stuff here ... 
$fullPath = $rooPath . $relPath .$imgPathGreen; 
// ... more stuff here ... 
} 

당신은 global keyword을 사용할 수 없습니다.

+0

해결되었습니다. 많은 감사 –

관련 문제