PHP Operators
By Darren W. Hedlund2005-06-20
This operator allowed us to assign values to variables and arrays (which we recently learned about).� The other PHP operator we discussed was the array operator
("=>") |
$variable = 'name'; //assign "name" to the variable $variable using the assignment operator |
$array = array('first' => 'something','second' => 'something else'); //assign array keys and values |
Pay particular attention to the above comments as some of them were not discussed in previous lessons.� In this lesson I'll go over some other common operators you might want to use.
The PHP arithmetic operators are used to do simple mathematical operations such as addition, subtraction, multiplication, and division.� Here are examples of each:
$number1 = 12; |
A few other common PHP operators you will find yourself using often are the following:
Here is a combination operator, concatenation and assignment in one.� This operator takes the original string and adds a new string onto it.
$string = 'hello'; //assign our original string |
Here is a combination operator, addition and assignment in one.� This operator takes the original number and adds a new number to it.
$number = 12; //assign our original number |
That's about it for this lesson.� There really isn't much to teach about PHP operators, you use them as you need them.� And if you don't know if what you want exists, you just check the PHP documentation.
Check out PHP's documentation for explanations of all the operators:
http://www.php.net/manual/en/language.operators.php
Tutorial pages:
|
|
|||||||||
You might also want to check these out:
|
Link to This Tutorial Page!

