Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

Output Variables

The PHP echo statement is commonly used to display data on the screen.

The following example demonstrates how to output text and a variable:

Example

$txt = "W3Schools.com";
echo "I love $txt!";

The following example will generate the same output as the previous one:

Example

$txt = "W3Schools.com";
echo "I love " . $txt . "!";

The following example will display the sum of two variables:

Example

$x = 5;
$y = 4;
echo $x + $y;