2010-06-07 79 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

我不认为你可以在HEREDOC块做操作。你必须预先准备变量。 – 2010-06-07 23:47:50

回答

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;