Conceptual differences between PHP and ASP

I am working on an open source PHP project for websites and as soon as I release version 1.0 I want to provide the same product for websites using the IIS / ASP.NET framework.

When the time comes, I will continue learning ASP.NET and translate, but it would be useful for me to know if there are fundamental conceptual or architectural differences between the two platforms. I want to keep this in mind when creating PHP so that the two codebases look as similar as possible, although there will of course be many differences in syntax names and library functions.

I think about things like variables / arrays, constant definitions, function namespaces, HTTP form and header handling. Anything that makes it difficult to view two codebases side-by-side and see a direct correlation between each line of code.

My PHP is backwards compatible with 4.x so I don't use exception handling or objects.

Are there any good articles or points on the internet about this?

+2


source to share


4 answers


There are incredible differences between PHP5 and .NET 3.5, depending on which version of ASP.NET you are using.

You need to learn the .net language first.

The .NET framework will take a lot of work to create some interactive components, so people might expect you to use them, so the pages will either look different, or you will need to do more work to get php to look like asp.net.



I think people's expectations will be the biggest obstacle in such an effort, and I agree with Matt Lacey that if there is a way to do it for you, you can just start with this, but you will want to learn C # or VB.NET ( I would suggest the first one) and do the translation yourself to better meet the expectations of your users.

Another big difference is that .NET provides several ways to create web services, so you will need to decide what is best for your product when you write it.

But if you have a good separation between the business logic and the view portion of your application, then the design of the view shouldn't change much.

+1


source


The differences between PHP and classic ASP are relatively small, so small that some kind of mechanical translation is possible. have a look at asp2php , which proves it can be done towards ASP towards PHP.

However, in the body of your question, you are specifying asp.net. Typically, ASP.NET uses a framework called webforms, which is designed to make web programming applications much more similar to desktop programming. This is very different from the native code supported by raw PHP, and in order to take advantage of ASP.NET, you will have to largely ditch your php code and use the application only as a functional example of how a .NET port should work. I've heard that it is possible to write a lot more ASP.NET scripting style that writes the answer directly, but I have no experience with this and you will find very minimal support for it.



In short: porting raw PHP to classic ASP should be easy. Both are scripting languages ​​that provide raw access to various HTTP variables and parameters and allow the programmer to write a response directly. If you are using a PHP framework or the ASP side as expected, if you are using ASP.NET then things will be different.

+1


source


Just to get rid of the chest. ... Why convert it at all? Running the same codebase on an IIS / PHP stack should be pretty straightforward.

Having said that, take a look at PHP on the ASP.NET Migration Assistant that Microsoft provides.

The page also contains a list of elements that can be converted (well, basically, anyway):

  • Language migration
  • Support for built-in functions
  • Include files
  • ...

As well as elements that cannot be converted (elements that you will have to completely overwrite):

  • Dynamic includes
  • Declare approval
  • PHP functions are incomplete in the current script.
  • ...
+1


source


Instead of trying and doing the translation to the language (and stack?) You are not familiar with what I would recommend looking at something like http://www.hawhaw.de/ to do the conversion / translation for you ...

0


source







All Articles