Home arrow PHP arrow Page 2 - PHP Operators

Assignment Operators - PHP

What can you do without operators? Not much, if you're trying to do without them in a programming language, and PHP is no exception. On Monday, we barely had time to show you a long list of the operators in PHP. Today, we're going to show you what they do.

TABLE OF CONTENTS:
  1. PHP Operators
  2. Assignment Operators
  3. Arithmetic Operators
  4. Incremental Operators
  5. Better by Comparison
  6. Logical Operators
By: James Payne
Rating: starstarstarstarstar / 20
October 31, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

We've already worked briefly with one of the assignment operators. Their basic function is to assign a value to a variable.


<html>

<body>


<?php

$example_variable = “An example”;

$number_variable = 1;


?>


</body>

</html>

Spark your memory? In addition to using the = operator, you can also add a value to your variable and reassign it the new value. Like this:


<html>

<body>


<?php

$initial_value = 10;

$initial_value +=;


?>


</body>

</html>

In the above example the variable $initial_value is set to 10. Then we take the value of $initial_value and add it to itself. The line $initial_value += is the same as writing $initial_value + $initial_value. Since the value is originally set at 10, the value is now 20.

It works the same with the rest of the assignment operators. If you had used the *= operator, it would have multiplied $initial_value by itself and resulted in the new value of 100.



 
 
>>> More PHP Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: