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.
blog comments powered by Disqus |
|
|
|
|
|
|
|