News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso:
Releasing unmanaged resources (a PHP port from C#'s "using" statement)
September 10, 2013 @ 10:55:44

In a new post to his site Gonzalo Ayuso has put together an example of releasing unmanaged resources similar to something C# does with its "using" functionality.

Sometimes we work with instances that needs to released even when exceptions happens. Something typical when we work with resources (Files, Database connections, ) [...] Sometimes I need collaborate with C# projects. C# is a great language. I really like it. It has a really cool feature to solve this problem: the "using" statement. Because of that we are going to build today one small library to implement something similar in PHP.

He provides a basic code example, showing how to use a "Disposable" interface with a "dispose" method that can be implemented based on the resource type you need to use. In his example, it's a "File" class that implements the interface and and global "using" function is defined to clean up the object after use. The code for the sample is also available on Github.

0 comments voice your opinion now!
release unmanaged resource csharp using tutorial

Link: http://gonzalo123.com/2013/09/09/releasing-unmanaged-resources-a-php-port-from-cs-using-statement/

blog comments powered by Disqus

Similar Posts

Sameer Borate's Blog: Generating a color palette from a image in php

DevShed: MySQL Table Prefix Changer Tool in PHP

Edin Kadribasic's Blog: PHP 5.2.0 RC4 Windows build available

SpinDrop.us: Using Zend Search Lucene in a symfony app

Wolfgang Drews\'s Blog: A Week in PHPWorld #1


Community Events





Don't see your event here?
Let us know!


threedevsandamaybe laravel unittest composer interview configure release conference framework community voicesoftheelephpant version symfony language introduction opinion podcast list api series

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework