-1
<?php

$author="Shweta";
print <<<END
this line 
is to test
END;

?>

Does anyone have an idea on why this does not work?

Kevin
  • 41,694
  • 12
  • 53
  • 70
tjshah050291
  • 71
  • 1
  • 2
  • 9
  • What does not work? It has a new line, but if you are looking in browser - it interprets the output as html code. Look into the source of the page - the new line is preserved. – Cheery Nov 04 '14 at 01:17

1 Answers1

0

Use this one:

<?php

$author="Shweta";
echo <<<EOT
this line 
is to test
EOT;

?>
Edward Manda
  • 559
  • 3
  • 7
  • And the difference is ... ? – Cheery Nov 04 '14 at 01:24
  • My point is that the new line should be preserved. But its not... Its showing the entire line "this line is to test" on one single line – tjshah050291 Nov 04 '14 at 01:29
  • @tjshah050291 it is preserved, do you know the difference between the plain text (`\n` - new line) and html (`
    ` for a new line)? Read this - http://stackoverflow.com/questions/12410695/new-line-n-in-php-is-not-working
    – Cheery Nov 04 '14 at 01:30
  • well now I do.... Thank you very much for your help! And sorry, the doubt was very silly.... trying php for the first time – tjshah050291 Nov 04 '14 at 01:36