PHP Classes – How to Create a Class

// remember to name the file PHPClassExample.php if we plan on using it as part of an includes file.

class PHPClassExample {

/*Define you variables and do an immediate value assignment*/
var $fname = "James";
var $lname = "Tadeo";

}

// create a class
$myPHPClass = new PHPClassExample;

/*Access the class value for the corresponding value, notice we don't need to add the $ in front of the variable, that's because
we already defined it in the class*/

echo $myPHPClass->fname;
echo $myPHPClass->lname;

?>

Testimonials

"Okay, obviously you're showing off here. NOBODY does turnaround times measured in minutes. = : ) Thanks again."
Jim Walker, James Walker Home Inspections
"THANK YOU JAMES YOU ARE INCREDIBLE! My sincerest thank you I really can't thank you enough..."
Bruno Marsala, HDMedia
"James has been a pleasure to work with. He gets stuff done efficiently, and listens to my every little gripe and comment. He's very good and I highly recommend him. "
Robert Nay, Nay Games LLC