Inspiration For Creative Minds
Home » Labs » PHP Class Example  

Filed under Labs

Here is a simple example of Class in PHP.

class EmpDetails {
var $property1;
var $property2; 
function display($name, $age) {
	print "Employee name is : $name<br>";
	print "Employee age is: $age<br>";
$obj = &new EmpDetails ;
$obj->name = 'Designer';
$obj->age = '26';
$obj->display($obj->name, $obj->age);

Another Example of Classes In PHP

ini_set('display_errors', 1); 
require_once 'Mysql.class.php'; 
class Test 
   private $db; 
   public function __construct() 
      $this->db = Mysql::singleton(); 
   public function listCustomers() 
      $result = $this->db->select('SELECT * FROM customers'); 
      return $result->getTable(true); 
$test = new Test(); 
echo $test->listCustomers();
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook

Posts you may like: