PHP Tutorials

What is Data Access Object Model in PHP ORM Architecture 0

What is Data Access Object Model in PHP ORM Architecture

Program 1 <?php class MyConnection { public function getConnection() { $mycon=mysqli_connect(“localhost”,”root”,””,”Library”) or die(“Connection not success”); return $mycon; } } ?> Program 2 <?php require ‘dao.php’; require ‘model.php’; ?> <html><head><title>This is test page of connection</title></head>...

PHP __toString() Method with Examples 0

PHP __toString() Method with Examples

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php class Product { private $pname; private $price; private $qty; public function __construct($name,$pr,$qt) { $this->pname=$name; $this->price=$pr; $this->qty=$qt; } public function __tostring() { //return “<br>This is to String method<br>”;...

PHP unserialize() Function with Examples 0

PHP unserialize() Function with Examples

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php class Employee { private $empname; private $empsalary; private $empdept; public function setdata($name,$sal,$dept) { $this->empname=$name; $this->empsalary=$sal; $this->empdept=$dept; } public function __construct() { echo “<br>This is Constructor method MYSQL...

Object Cloning in PHP 0

Object Cloning in PHP

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php class Employee { public $empname; public $department; // sub object of department class public function __construct($ename,$d1) { $this->empname=$ename; $this->department=$d1; } public function __clone() { echo “<br><font color=red>***********This...

PHP Namespaces and Require 0

PHP Namespaces and Require

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php class MyMath { public function addition($a,$b) { $c=$a+$b; return $c; } public function subtraction($a,$b) { $c=$a-$b; return $c; } public function max($a,$b) { if($a>$b) return $a; else...

PHP isset() Function with Examples 0

PHP isset() Function with Examples

Program 1 <html> <head><title>Demo</title></head> <body> <center> <form method=post action=TestIsSet.php> Name:<input type=text name=txtname> <br> Department:<input type=text name=txtdept> <br> Salary:<input type=text name=txtsalary> <input type=submit value=Submit name=btnsubmit> </form> <?php class Employee { public $empname; private $empdept; private...

Constructor and Destructor in PHP 0

Constructor and Destructor in PHP

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php class Test { public $mycon=null; public function __construct() { //echo “This is a constructor.<br>”; $this->mycon=mysqli_connect(“localhost”,”root”,””,”Library”) or die(“Connection not success”); echo “Connection open success<br>”; } public function display()...

Method Chaining in PHP 0

Method Chaining in PHP

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php class A { function first() { echo “This is a first method of class A<br>”; return $this; } function second() { echo “This is a second method...

Traits in PHP Part – 2 0

Traits in PHP Part – 2

Program 1 <html> <head><title>Demo</title></head> <body> <center> <?php trait display { public function displaydata() { echo “<font color=green>Hello Friends How are you this is display data method of trait display…..</font><br>”; } } trait show {...