O'Reilly logo

PHP for Teens by Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Expressions

Expressions are basically the most important element of PHP. In essence, anything that you write in PHP, anything that has a value, is considered an expression. If you create a statement that does something, it is generally an expression.

A very simple example of an expression—creating and assigning a variable—might look something like this:

$variablename = "value";

This creates a variable called variablename that is assigned to some value. Because "value" is a string, the variable $variablename will also be a string. See the semicolon at the end? That marks the end of a statement.

What is the difference between a statement and an expression?

Statements and expressions are both very common and very important. All statements are expressions, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required