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)
Sep 10, 2013 @ 15: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.

tagged: release unmanaged resource csharp using tutorial

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

Jeff Moser's Blog:
Notes from porting C# code to PHP
Oct 26, 2010 @ 17:49:08

In a new post to his blog Jeff Moser takes you through some of his experiences in port code from C# to PHP as a first-time PHPer and learning right from a book.

After years of hearing negative things about PHP, I had been led to believe that touching it would rot my brain. Ok, maybe that's a bit much, but its reputation had me believe it was full of bad problems. Even the cool kids had issues with PHP. But I thought that it couldn’t be too bad because there was that one website that gets a few hits using a dialect of it. When Kaggle offered to sponsor a port of my TrueSkill C# code to PHP, I thought I'd finally have my first real encounter with PHP.

He starts with a few disclaimers, noting that the structure of the application was kept largely the same and that he didn't go much into the web or database functionality that PHP's well known for. He talks about the book he chose to learn from (Beginning PHP 5.3) and includes some excerpts from the author talking about the PHP language. He splits up the rest of the post into several different sections covering his thoughts on the whole process:

  • The Good Parts
  • The "When in Rome..." Parts
  • The "Ok, I guess" Parts
  • The Frustrating Parts

Unfortunately, the "Good" parts section is one of the smallest.

tagged: port experience csharp trueskill

Link:

Juozas Kaziukenas' Blog:
Using PHP with C# written libraries
Apr 23, 2009 @ 12:57:17

Juozas Kaziukenas has written up a new post (as a part of his participation in the WinPHP Challenge) about how he's combined C# code with PHP code in his development.

Actual PHP part is very easy to write, because only thing you need to do is to create COM object. However, making your dll’s visible by PHP is a bit tricky.

He points to this tutorial as a starting point and issues he had with ComVisible and some example code that finally got things working.

tagged: language combne winphp09 winphpchallenge09 library csharp

Link:


Trending Topics: