开发者

php heredoc syntax question

开发者 https://www.devze.com 2023-01-03 03:45 出处:网络
Trying to output the following 5 but not sure how to do it. Any ideas? <?php $other=\'What are you like?\';

Trying to output the following 5 but not sure how to do it. 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 . '<开发者_Python百科;br />';


As Pekka correctly stated:

$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..

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

精彩评论

暂无评论...
验证码 换一张
取 消