0

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 . '<br />';
1
  • 6
    I don't think you can do operations in HEREDOC blocks. You would have to prepare the variable beforehand. Commented Jun 7, 2010 at 23:47

1 Answer 1

3

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.