2010-06-07 4 views
0

다음 5 개를 출력하려고하지만 확실하지는 않습니다. 어떤 아이디어?PHP heredoc 구문 질문

<?php 

$other='What are you like?'; 
$content['my_name']=4; 

$str=<<<JT 
    here is some info. $other Do 
    you like the number {$content['my_name']+1} ? 
JT; 

echo $str . '<br />'; 
+6

난 당신이 히어 닥 블록에서 작업을 할 수 있다고 생각하지 않습니다. 변수를 미리 준비해야합니다. –

답변

3

로 페카 제대로 진술 :

$str=<<<JT 
    here is some info. $other Do 
    you like the number {$content['my_name']+1} ? 
JT; 

이 유효하지 않습니다 - 전용 변수는 히어 닥에 구문 분석됩니다 ..

$content['my_name'] += 1; 
$str=<<<JT 
    here is some info. $other Do 
    you like the number {$content['my_name']} ? 
JT;