PHP text generation

From Wiki @ Karl Jones dot com
Revision as of 19:08, 19 September 2016 by Karl Jones (Talk | contribs)

Jump to: navigation, search

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()

<?php
echo ("Hello", " ", "World");
?>

Shortcut syntax

PHP also provides a shortcut for echo:

I have <?= $foo ?> foo.

The above shortcut generates whatever text is in the variable named $foo.

See also

External links