MaggsWeb:7

www.maggsweb.com


Taken from http://mypaaji.com/Index.php/php-quick-reference/


<?php
class ClassName() // class definition
{
	public $var1; // property with public access
	private $var2; // property with private access
 
	// constructor method
	public function __construct() {
		// code to initialize object goes here
	}
 
	// public method
	public function setFoo($value) {
		// properties and methods are accessed inside the class
		// using $this->
		$this-> var2 = $value;
	}
 
	// private method
	private function bar() {
		// more code goes here
	}
 
	// destructor method
	public function __destruct() {
		// clean up code goes here
	}
}
$c = new ClassName(); // create a new instance of the object
$c-> var1 = 42; // properties and methods are accessed using - >
$c-> setFoo('Hello World');
 
?>
Share this:
  • Print
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • Twitter

Write a Comment

Let me know what you think?