<p>I am used to writing C# Windows applications. However, I have some free hosted PHP webspace that I would like to make use of. I have a basic understanding of PHP but have never used its object-oriented capabilities.</p>
<p>Is there an easy way to convert C# classes to PHP classes or is it just not possible to write a fully object-oriented application in PHP?</p>
<p><strong>Update:</strong> There is no reliance on the .NET framework beyond the basics. The main aim would be to restructure the class properties, variable enums, etc. The PHP will be hosted on a Linux server.</p>

[{'answer_id': 13648, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>A huge problem would be to replicate the .Net Framework in PHP if the C# class usses it.</p>\n'}, {'answer_id': 13658, 'author': 'Vincent Robert', 'author_id': 268, 'author_profile': 'https://Stackoverflow.com/users/268', 'pm_score': 0, 'selected': False, 'text': "<p>I don't know about a tool to automate the process but you could use the Reflexion API to browse your C# class and generate a corresponding PHP class.</p>\n\n<p>Of course, the difficulty here is to correctly map C# types to PHP but with enough unit testing, you should be able to do what you want.</p>\n\n<p>I advice you to go this way because I already did a C# to VB and C++ conversion. That was a pain but the result was worth it.</p>\n"}, {'answer_id': 13663, 'author': 'John Downey', 'author_id': 200, 'author_profile': 'https://Stackoverflow.com/users/200', 'pm_score': 3, 'selected': True, 'text': '<p>It is entirely possible to write a PHP application almost entirely in an object-oriented methodology. You will have to write some procedural code to create and launch your first object but beyond that there are plenty of MVC frameworks for PHP that are all object-oriented. One that I would look at as an example is <a href="http://codeigniter.com" rel="nofollow noreferrer">Code Igniter</a> because it is a little lighter weight in my opinion.</p>\n'}, {'answer_id': 14232, 'author': 'JProgrammer', 'author_id': 1675, 'author_profile': 'https://Stackoverflow.com/users/1675', 'pm_score': 0, 'selected': False, 'text': '<p>If the problem is that you want to transition to PHP and you are happy to continue running on a windows server with .NET support you might consider wrapping your code using <a href="http://swig.sourceforge.net/" rel="nofollow noreferrer">swig</a>.</p>\n\n<p>This can be used to generated stubs to execute from php and you can then go about rewriting the .NET code into PHP in an incremental fashion.</p>\n\n<p>This works for any of the supported languages. ie. you could incrementally rewrite an application in c++ to java if you really wanted to.</p>\n'}, {'answer_id': 15672, 'author': 'maetl', 'author_id': 14446, 'author_profile': 'https://Stackoverflow.com/users/14446', 'pm_score': 3, 'selected': False, 'text': "<p>PHP doesn't support enums, which might be one area of mismatch.</p>\n\n<p>Also, watch out for collection types, PHP despite it's OO features, tends to have no alternative to over-using the array datatype. Check out the sections on the PHP manual on iterators if you would like to see beyond this.</p>\n\n<p>Public, protected, private, and static properties of classes all work roughly as expected.</p>\n"}]
['https://Stackoverflow.com/questions/13647', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/33/']