Learn PHP:13-Understanding Expressions in PHP

Posted: November 3, 2010 in PHP

PHP is an expression-oriented language, in the sense that almost everything is an expression. An expression in PHP is anything that can be used as a value. Including integer constants, variables, and function calls. It is any combination of values, variables, operands, and functions that sets a value. If it can be used as if it were a value, it is an expression in PHP. When we take a variable and use an operator on it or a pair of variables we have created an expression in PHP. PHP expressions are best defined as “anything that has a value”.

When we create simple variables we are using expressions: 

$var1 = 10; // 10 is an expression with an integer type value of 10
$var2 = $var1; // $var1 is an expression with an integer type value of 10


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s