Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Object?

Status
Not open for further replies.

laurin1

MIS
Apr 28, 2003
77
US
If i have a code like this:

Code:
class MyClass{

var $sProperty;

function MyMethod(){

echo $this->$sProperty}

}

}

function A(){

$oTest = new MyClass();
$oTest->sProperty = 'Hello World";
$oTest->MyMethod();

}

function A(){

$oTest = new MyClass();
$oTest->sProperty = 'Goodbye World";
$oTest->MyMethod();

}

Is there any way to reuse the same object, or some more efficient method rather than creating the object each time? I have quite of few of these and it seems silly to have to do it this way.

Keith Davis
MCSA, A+, N+, Guru+, Geek+, Child of God++++++
Love and Service
 
no reason (sfaik) why you can't make an object global
Code:
$GLOBALS['whatever'] = new myclass();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top