Jump to content

OOP Memory Management


Guest Carl

Recommended Posts

Just a quick question.

 

I have just watched the videos on OO programming in PHP and I recommend them they are very good.

 

One question I have is, is it necessary to free an object at the end of a script? Like in other languages?

 

And how is it possible to have a created object available to other scripts.

 

For example crate an object in script a.php set some variables and have script b.php reference it? Or is that not possible.

 

Kind regards

Carl...

Link to comment
Share on other sites

Hi,

 

To answer your questions:

 

One question I have is, is it necessary to free an object at the end of a script? Like in other languages?

 

No. Once a script executes it is dumped. ... although it is probably a good idea to free up resources as soon as you can. Contrast this to Java, where you should explicitly free up resources ... even though there is garbage collection.

 

 

 

And how is it possible to have a created object available to other scripts.

 

Use php session. That is to say, stick them in session.

 

You should take a look at our PHP shopping cart video course because it covers these kinds of things. In fact the Shopping cart screencast is really a vehicle to teach a little bit more advanced PHP.

 

Stefan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...