PHP is a language. PHP consists of a platform-independent engine that parses PHP scripts. This language also provides common web application functionality such as database connectivity.
ASP.NET is not a language, but a technology and is a small part of the .NET Framework. The Dot NET Framework consists of a) CLR – Common Language Runtime which manages execution of the code b) a hierarchical set of class libraries. These libraries are extensive and provide a great deal of functionality both for web-based applications and well as windows-based.
ASP.NET framework is built entirely on an OOP paradigm and OOP concepts while PHP is not.
PHP does not follow the OOP paradigm entirely. It only supports partial encapsulation, and partial polymorphism.
Compilation is also different in PHP and ASP.NET.
In PHP, when a page is requested, the HTML and inline PHP script is compiled to binary format called Zend Opcodes. Once compiled, the opcodes are run by the Zend Engine and HTML is generated which is sent to the client. Commercial products are available that increase the speed at which PHP pages are executed.
In contrast, when an ASP.NET page is first requested it is converted into an intermediate language called MSIL (Microsoft Intermediate Language). The CLR then converts this MSIL to machine code. Conversion to machine code only takes place once for each page request (unless code has been modified). All subsequent requests use the already generated machine code. In ASP.NET no optimization product is required as the MSIL generated is already in its most optimized form.