开发者

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

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 9 years ago.

Improve this question

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 compariso开发者_运维问答n. Heavens knows there are already enough of those on the web.


The more of problem would be from PHP->.NET/C# as PHP offers too much flexibility, that's why everyone seems to be good at programming in PHP, but trust me, the software monsters that I have seen in my life are 80% on PHP. Advice from a 70% PHP - 30% Java developer: keep the standards and everything will be allright. PHP can trick you with it's flexibility: loose typed, built-in template engine, Objects that are basically associative arrays, odd error handling, strings that can be treated easily as class,variable and function names.

If I would make a comparison: Java = Military Dictatorship (That is why Java is my favourite programming language) PHP = Hippie Haven (Where I do my best to be a standard technological tyrant), where there are no laws you must rely on "common sense", if you lack "common sense"... well, it results in chaos.

To see a small comparison I recommend that you take a look in the sources of eFront elearning platform (it's an open source eLeraning solution with excellent business needs coverage and horrid coding)

To see the opposite take a look at Joomla or Magento sources. (they have great business coverage also in their field).

If you get on PHP make sure you stay on the bright side.


From a language perspective, PHP is loosely typed. This is quite important, and can make quite a big difference. But as long as you're careful with it, and use === rather than == when appropriate, it shouldn't trip you up. (it can actually make things easier in many cases)

But the really big difference you're going to notice a lot is the fact that you don't have the .NET framework to play with. All those useful methods it provides for doing stuff; gone.

In its place, in a vanilla PHP installation at least, are a huge array of inconsistently named function and class libraries.

The PHP manual is an excellent resource for learning all these function - possibly one of the most comprehensive and genuinely useful manuals on the web. It makes PHP very accessible, and you should be able to find the functions you're looking for in most cases.

But if you really want a decent framework library, you should seriously consider looking at one of the well known PHP frameworks, and install and learn that at the same time as you learn PHP. I would suggest looking at Symphony or CakePHP, but there are a number of others that would also be worth investigating. Whichever you pick, if you're used to an MVC development pattern, these frameworks will make your introduction to PHP much much easier.

Hope that helps.


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.


http://www.php.net is your friend, read the comments when you're going through the functions, lots of lessons learned there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜