May 9, 2013
In PHP, how do I call master class functions to different pages?
Gopinath’s Questions:
I have master class for the whole project. I need to call master class functions to different pages and methods as described below:
Master.php
class master{
function login_parser(){
}
}
Index.php
include('master.php')
function test(){
$obj = new master();
}
function test2(){
obj = new master();
}
I need to call object for every method. Is there any way to call an object in single time?
Yes, Instead of creating object everytime. Create on outside the functions on global scope.
include('master.php')
$obj = new master();
function test(){
global $obj; //Now carry on
}
function test2(){
global $obj;
}