Search code examples
phpasp.netwindowslamp

What should an experienced Asp.net programmer know when jumping into PHP?


I would like to think of myself as a somewhat experienced asp.net/c# programmer. I love asp.net's object-oriented goodness. I love it's typed variables. I love working in Visual Studio.

However, this afternoon, I was punched in the face with the desire to write a web-application using php/mysql.

I am wondering, S.O., as a confident Asp.net programmer, what do I need to know about the fundamentals of PHP (whole lamp system I suppose) that will ease the learning curve?

Are there comparisons or analogies you can make? Tricks cross-overs like me fall for? Etc?

One thing I'm not looking for is an argumentative or biased comparison. Heavens knows there are already enough of those on the web.


Solution

  • If you're moving from ASP.NET WebForms (I'm assuming you are) the biggest thing you'll need to realize is that the plethora of classes that .NET provides you for web development are nonexistent in PHP - nothing wrong with that: PHP provides you with much greater control to take your web app in whatever direction you want to go.

    In short, ASP.NET is a full blown framework for developing web applications, PHP is simply a programming language. Like .NET, however, there are frameworks for helping you build web apps.

    The biggest things you'll need to remember:

    1. No code-behind pages. PHP does not support partial classes so you can't have this functionality. Some frameworks, like Prado, do an admirable job of mimicking this.
    2. No view state. You will need to manually handle GET and POST data.
    3. No controls. If you aren't familiar with it already, you will definitely need to have a good grasp of how to write your own HTML and push data to them.
    4. File management - you will need to load files manually using include or require. Since PHP is not a compiled application, you will need to manually include each file you intend to use.