KurtNovice
KurtNovice

Reputation: 63

Multiline echo PHP not working

I'm new to PHP and I bought this book that told me to download XAMPP and installed it on my laptop. It installed fine but when I started coding, I noticed the multiline echo doesn't work. I tried uninstalling and reinstalling a later version, still it doesn't work. And I tried to install WAMP from another website and still it doesn't work. My code looks like this

<?php
  $author = "Bill Gates";

  $text = "Measuring programming progress by lines of code is like
  Measuring aircraft building progress by weight.

  - $author.";
echo $text;
?>

All I get is this in single line.

Normal people believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. - Scott Adams.

I'm using Windows 7. Anybody who has an idea what's wrong, please do reply.

Upvotes: 0

Views: 234

Answers (2)

Jaya Vishwakarma
Jaya Vishwakarma

Reputation: 1332

Here HTML tag <br /> can help you:

<?php
      $author = "Bill Gates";

      $text = "Measuring programming progress by lines of code is like
      Measuring aircraft building progress by weight.
        <br /><br />
      - $author.";
    echo $text;
    ?>

Here you can see examples: http://www.w3schools.com/tags/tag_br.asp

Upvotes: 0

maxhb
maxhb

Reputation: 8845

Instead of

echo $text;

use

echo nl2br($text);

See https://secure.php.net/manual/en/function.nl2br.php

Upvotes: 1

Related Questions