简体   繁体   English

php heredoc语法问题

[英]php heredoc syntax question

Trying to output the following 5 but not sure how to do it. 尝试输出以下5条信息,但不确定如何执行。 Any ideas? 有任何想法吗?

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

As Pekka correctly stated: 正如Pekka正确指出的那样:

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

is invalid - only variables are parsed in the heredoc.. 无效-在Heredoc中仅解析变量。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM