HTML and CSS Reference
In-Depth Information
Everything but the 1 was probably expected. Some languages will treat Booleans as either a
true/false or 1/0 pairs. So true + true = 2, and true * false = 0.
h e $testPM object is the object, and it works just like every other object in other lan-
guages. In JavaScript, though, the object and property are separated by dots ( . ) while in PHP,
they're separated by arrows ( -> ). h e following are equivalent:
myObject.myProp = 20 ; //JavaScript
myObject -> myProp = 20 ; //PHP
Yo u ' l l i nd other dif erences, but the similarities are far more numerous between PHP and
Like all Web languages, PHP has operators, and a full listing of them can be found in the
oi cial PHP manual at
php . Here, just a few that will be used in the program to make an email application, and some
others are unique in other ways. So while you'll have to depend on the manual for all PHP
operators, the one examined in the next few sections will have you up and running.
To assign a value to a variable or object, the equal sign ( = ) serves as the assignment operator.
Compound PHP operators assign the value of the current variable plus, minus, multiplied by,
or divided by the assigned value. h e following example ( assignment.php in this chapter's
folder at ), shows the key uses of assignment
$sampleNum = 20 ;
$sampleString = ”Hurricane” ;
$sampleNum += 50 ;
$sampleString .= “ is coming.” ;
echo $sampleNum , ”<br>” ;
$sampleNum *= 2 ;
echo $sampleNum , ”<br>” ;
$sampleNum /= 4 ;
echo $sampleNum , ”<br>” ;
echo $sampleString ;
Before you look at the outcome, see if you can predict what they'll be:
Hurricane is coming .
Search WWH ::

Custom Search