How may I use the same object in more than 1 script?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Xpucto
Forum Newbie
Posts: 1
Joined: Tue Dec 17, 2002 5:28 am

How may I use the same object in more than 1 script?

Post by Xpucto »

Hi!
How may I maintain an object in more than one script? As soon as I want to use an object in more than one script, I have this problem that I don´t know how to transmit this object to other scripts.

Thanks
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Passing Instances?

Post by EricS »

Are you asking if you can pass instances of objects from one page to another?
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

When you say "object" are you speaking of an already instantiated entity? Remember, there is a subtle difference between class and object. A class becomes an object when it is instantiated.

That said, it's no problem to include and use the same class in each of your scripts by just including the code for it with a include() or require() function or construct. On the other hand, if what you want is some free running object that each of your scripts can interface with when they're run, you need to take a look at something like SRM or create a php sandbox of some sort.

Cheers,
BDKR
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

If you want to store data like username and password etc. You will probably be best with using a database or a file to store it.
Post Reply