Author: Robert Lair and Jason Lefebvr Intensity Software, Inc.
Translation: EasyChen Exlcsoft.com
Overview
An ongoing debate in the development circle is about which platform in PHP and ASP is more suitable for website development. This debate has entered a new era due to the huge changes brought by Microsoft's ASP.net. Compared with ASP 3.0, ASP. NET adopts a brand new design with many new features and advantages. What is the impact of ASP. NET on the debate between PHP and ASP? This article will provide you with information about the answer to this question.
Architecture comparison
PHP
PHP4.0 takes Zend Technologies's Open Source Engine Zend Engine as the core. When your browser sends a request to a network server implemented by PHP, the request is sent to Zend Engine, which will compile the php script. If the compilation succeeds, the compiled code will be passed to the Zend Engine Executor that generates the final HTML code sent to the client. From the developer's perspective, the PHP 4.0 framework has both advantages and disadvantages.
Because PHP is open-source, it is supported by many different platforms and web servers. Although it is larger than the previous PHP Engine, Zend Engine is still light and strong. As an extension, PHP also supports object-oriented, allowing users to create their own classes and objects. However, for some reason, PHP is not a real object-oriented development environment. The best example is the scope of the class member functions and attributes. In PHP, all variables in a class can be read and written from outside, which makes the implementation of the class invisible.
In addition, PHP is not a strongly typed language (that is to say, if you compare character 4 and integer 4, the result is the same), which brings problems in the architecture of large programs, it also makes program debugging difficult. To make debugging more difficult, you don't even need to declare variables, which is similar to ASP that turns off the explicit it option. If PHP encounters a new variable in the script, it will only create it quietly.
Although considered as the flexibility of a loose PHP framework, every developer may spend several hours solving bugs caused by this feature in some cases. Objects are language-level variables in PHP. They are largely processed as simple variable types. (Just like integer and balanced variables) When performing operations like variable assignment and passing an object as a parameter to a function, the entire object is copied. This will lead to inefficiency. In addition, unpredictable runtime behaviors often occur.
PHP lacks some other key elements of the vast majority of modern development frameworks. The most important one is structured exception capturing. Although an error handler can be registered for a process error, it is not convenient for the language itself. Due to the absence of "try... catch" error capture, many PHP developers forget to capture errors or use them in a narrow range.
ASP. NET
The core of ASP. NET is the Microsoft. NET Framework. This framework provides common language runtime (CLR) and class libraries, and ASP. NET is built on this.
When an ASP. NET Resource is requested for the first time, the high-level language code (such as Microsoft Visual Basic®. NET or C #) is compiled into Microsoft Intermediate Language (MSIL) code. This code will be run by CLR to generate machine code for Web Services.
ASP. NET forces developers to use real object-oriented programming. All objects are real OO objects and support inheritance, polymorphism (method overloading), and encapsulation features.
In addition, all languages in ASP. NET are strongly typed. For example, to compare integers 4 and 4, you must first convert the variable to an integer, and vice versa.
ASP. NET adopts an event-driven programming model, which means that code snippets are linked by events that may occur during program running.
For example, place the Page_Load () event on the ASP. NET page to the code that will run when the browser reads the Web form. Many additional events are associated with ASP. NET Page objects. developers can execute code at any time in their lifecycles. Similarly, each control on a Web form has a series of events that can execute code upon triggering. For example, by adding a button to a Web form, you can add a method (called a delegate) to execute it when a user clicks the button. Almost all controls have one or more events.
You can access the Class Browser example provided by Microsoft in the QuickStart guide.
Easy Note: This article is translated from MSDN and is part of PHP vs. ASP. NET. Other parts of the article are Easy to translate based on events and energy.