HTML and CSS Reference
In-Depth Information
You'll see the following output:
value2
valueEtc
computer parts
tools
second3
Arrays are important in PHP because database data are ot en loaded into an array for output.
Objects and properties
Objects in PHP are based on user classes — there's no Object() object like there is in
JavaScript. Making a class is like creating an object with all the variables, arrays, constants,
and functions you like in one place. Here are the basics of creating a class, adding properties,
and adding methods in this example ( PropMethod.php in this chapter's folder at www.
wiley.com/go/smashinghtml5 ):
<?php
class PropMethod
{
private $propString = ”I work well with HTML5” ;
private $propNum = 2044 ;
private $propBool =true;
public function showString ()
{
echo $this -> propString , “<br>” ;
}
public function showNum ()
{
echo $this -> propNum , “<br>” ;
}
public function showBool ()
{
echo $this -> propBool ;
}
}
$testPM = new PropMethod ();
echo $testPM -> showString ();
echo $testPM -> showNum ();
echo $testPM -> showBool ();
?>
335
h e output for that little class is:
I work well with HTML5
2044
1
 
Search WWH ::




Custom Search