PHP syntax: variable assignments

Home -> Programming -> Web -> PHP

6340 views

From the computer of: qmchenry (337 recipes)
Created: Dec 27, 2003     Updated: Jun 19, 2006


0 comments:
View all comments

Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL







To assign the value "Tolkien" to the variable $author:

$author = "Tolkien";


Once assigned, additional strings can be added to a variable using the dot operator:

$author .= ", J.R.R.";
// results in $author containing "Tolkien, J.R.R."


The dot operator is like an addition operator for strings:

$var = "The author is ".$author;
// $var would contain "The author is Tolkien, J.R.R."

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  PHP syntax: for loop basics
  PHP comparison syntax: equality
  PHP: Rename or move a file on the server
  PHP conditional syntax: inequality
  PHP syntax: comments
  PHP syntax: iterate over an associative array
  PHP: determine the directory path of the server root
  PHP conditional syntax: less than
  PHP syntax: create an associative array
  PHP syntax: iterate over an array

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.