Difference between revisions of "PHP text generation"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) (→echo()) |
Karl Jones (Talk | contribs) (→echo()) |
||
Line 17: | Line 17: | ||
== echo() == | == echo() == | ||
− | You can use echo with | + | You can use echo with multiple parameters, to combine text and variables. |
The example below uses two variables named $word1 and $word2. | The example below uses two variables named $word1 and $word2. | ||
Line 25: | Line 25: | ||
$word1 = "Hello"; | $word1 = "Hello"; | ||
$word2 = "World"; | $word2 = "World"; | ||
− | echo | + | echo $word1, " ", $word2; |
?> | ?> | ||
</pre> | </pre> |
Revision as of 08:37, 29 September 2016
The PHP programming language provides several ways to generate text.
The echo keyword is the most common way.
In a PHP-based web application, generated text becomes part of the response that the web server return to the client.
echo
A simple echo:
<?php echo "Hello World"; ?>
echo()
You can use echo with multiple parameters, to combine text and variables.
The example below uses two variables named $word1 and $word2.
<?php $word1 = "Hello"; $word2 = "World"; echo $word1, " ", $word2; ?>
Shortcut syntax
PHP also provides a shortcut for echo:
$msg = "Hello World"; This is HTML, lorem ipsum, <?= $msg ?>, more HTML etc.
See also
External links
- [1] @ php.net