php heredoc语法问题

时间:2010-06-07 23:43:23

标签: php

尝试输出以下5但不确定如何操作。有任何想法吗?

<?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 />';

1 个答案:

答案 0 :(得分:3)

正如佩卡所说:

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

无效 - 只在heredoc中解析变量..

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