Search code examples
phpobjectmemory-managementprogramming-languages

Do I need to release the object in php?


Previously I've used Objective-C in iPhone Development. It seems I need to do some work in the back-end site, I chose PHP for this. In Objective-C, I need to release objects after I use them. Do I need to do this in PHP also? Thank you.


Solution

  • 99.9% of the time, no you do not need to delete the object. PHP has a garbage collector that will handle that for you. The garbage collector will free a given instance of memory once it is no longer needed in your code.

    To read more:

    http://php.net/manual/en/features.gc.php