Since my updated reference book (Beginning PHP 4, Wrox Publishing) doesn't refer to $GET, $POST, or $_REQUEST, I can't figure out how to add a line break between variables returned from an HTML form. Thanks to some of you smart folks, I was able to figure out how to get the information from the form to the PHP script, but now I want to format it. The PHP script reads:

<?php
echo $_POST['Choice1'];
echo $_POST['Choice2'];
echo $_POST['Choice3'];
?>

and returns:

choice1choice2choice3

How can I either add a space between the returned variables, or add a line break after each of the first two returned variables? Any assistance would be greatly appreciated.

    strings are combined with .

    echo "hello" . " " . "world";
    would display the same as
    echo "hello world";

    a linebreak itself is "\n", but often you'll need <br> when displaying html

    <?php
      echo $_POST['Choice1'] . "\n";
      echo $_POST['Choice2'] . "\n";
      echo $_POST['Choice3'] . "\n";
    ?>

    note that browsers don't always show linebreaks like \n
    (you can see them in source code though)

      Simply like this :

      <?php
      echo $_POST['Choice1'] . "<BR/>\n";
      echo $_POST['Choice2'] . "<BR/>\n";
      echo $_POST['Choice3'] . "<BR/>\n";
      ?>

      The explications...

      echo is used to output data.

      You can simply output some text without any variable...

      echo "Hi ! My name is Suntra.";

      You can output only one variable...

      echo $variable;

      You can output text and variable(s)...

      echo "Hi $visitor_name ! My name is Suntra.";

      You can output text and variable(s) from an array...

      echo "Hi $_REQUEST[visitor_name] ! My name is Suntra.";

      You can also output text and variable(s) this way :

      echo "Hi " . $visitor_name . " ! My name is suntra.";

      For variable(s) from an array...

      echo "Hi " . $_REQUEST["visitor_name"] . " ! My name is suntra.";

      The principle is simple...

      echo "[text]" . [phpcode principally variables] . "[text 2]" . [phpcode 2] (...) . "text n] . [phpcode n];

      Is it clear enough ?! I'm not sure... !

        Write a Reply...