PHP vs. asp (a) _php

Source: Internet
Author: User
Keywords front PHP one use feature object code process ASP.
Tags odbc what is asp
Today, when it comes to WEB development, you have many choices. Many of these methods involve preprocessing-that is, using specific tags to embed code into an HTML page that tells the preprocessor that they contain code and that they should be processed. Very similar to CGI, the code runs on the server and returns some content that behaves as a partial appearance of the resulting HTML page that is sent back to the browser. The open source scripting language is this type of language in PHP and Microsoft's ASP. JavaServer Pages (JSP) and Perl/mason are also running this way.

In this article, I'll focus on the technologies that Php-oracle has chosen to incorporate into its products-and ASP. I'll outline the strengths and weaknesses of both, and focus on the factors that will help you decide which technology you should choose for your development project. There are many factors to consider, and different projects may resort to different technologies. In summary, you'll see an itemized comparison of price, speed and efficiency, security, cross-platform support, and the benefits of open source solutions.

What is ASP.

ASP's latest version of ASP. NET is not completely compatible with earlier versions of ASP because the software was completely rewritten. Early ASP technology actually has much more in common with PHP than with ASP. ASP. NET is a complete framework for building WEB applications. One of the main features of this model is the flexibility of choosing a programming language. ASP. NET can use scripting languages such as VBScript, JScript, PerlScript, and Python, as well as compiled languages such as VB, C #, C, Cobol, Smalltalk, and Lisp. The new framework uses the common language runtime (CLR), which compiles the source code for your language into the Microsoft intermediate language code, which is then executed by the CLR.

The framework also provides true object-oriented programming (OOP) and supports true inheritance, polymorphism, and encapsulation. The. NET class Library is organized into inheritable classes based on specific tasks, such as using XML or image processing.

In addition to programming languages and methods, database access is also a factor to focus attention on. When you are programming with ASP, you can integrate the database with ODBC, and ODBC provides a consistent set of calling functions to access your target database.

Strengths and weaknesses

The advantage of ASP is clearly the simplicity of its design and implementation. This is the dream of object-oriented programmers: The language is flexible and supports complex object-oriented features. In this sense, it really works with the programmer's existing skills to interoperate.

Another advantage of ASP is its development environment. For example, developers can use WebMatrix (a community-supported tool), Visual Studio. NET, or various Borland tools such as Delphi and C + + Builder. For example, Visual Studio allows you to set breakpoints, track code snippets, and view the call stack. In summary, it is a complex debugging environment. Many other third-party ASP. NET IDE solutions will also inevitably occur.

But you get the robustness, you will be at the cost of loss of efficiency. ASP is very expensive in terms of memory usage and execution time, mostly due to the longer code path. For web-based applications, these limitations can be a serious problem, because on the Web, your application may expand to tens of thousands of users per second. Memory usage can also be an issue on the WEB server.

What is PHP?

PHP is a scripting language based on the preprocessing of HTML page models. When the PHP preprocessor in the WEB server discovers a PHP language tag like the following, the PHP engine is invoked to execute the code:

Some code here
?>



Any programmer who uses an imperative programming language will be familiar with PHP, and you will find it similar to Perl, C, and Java in syntax. Strictly speaking, Java is an imperative programming language, but it also takes advantage of object-oriented architecture and concepts. PHP draws on this structure when it's appropriate, but it's not a purely OOP language.

In the above discussion of ASP. I mentioned the ODBC driver and how to build the application in the context of database abstraction. In PHP, you can also use ODBC to talk to a database, so you already have a list of supported databases to choose from. There are also native drivers for MySQL, Oracle, and Postgres. In addition, if you are using Oracle, there is a special OCI8 library that provides additional access to Oracle, allowing you to use features such as LOB, BLOB, CLOB, and BFILE.

You might then ask, "Why is database-related repositories called PHP features?" "Database abstraction or independence is a factor to consider when you try to build applications that use multiple databases or that require porting between databases, such as porting from development to production." And these really should be cared for and considered.

But as Tom Kyte in his new book-effective Oracle by Design (Oracle Press)-database affinity will be your real goal, because it will maximize your investment in the technology. If you have general access to Oracle-regardless of the ODBC or Perl DBI Library, you will not be able to use features that other databases do not have. In addition, optimized queries vary in each database.

Zend Technologies is a commercial software company that makes a significant contribution to PHP. It creates a business development environment called Zend Studio, which contains a complex debugger, a monitor, and other features. The company also built a free Zend Optimizer, which is used in conjunction with Zend Encoder to compile PHP code to improve performance. There are other commercial products, such as Zend performance Suite, which can cache precompiled PHP pages, further significantly improving overall performance.

Strengths and weaknesses

Up to Beta 4, PHP 5 still has some drawbacks, including missing exceptions and event-based error-handling routines that interrupt normal program flow and redirect code to a special error-handling section. Java also provides exceptions for error handling, while C + + provides exception handling through the try, catch, and throw syntax. Of course, you can still manage errors in PHP, but the structure is not standardized, so that programmers must use their own tools to determine how to perform error handling, which leads to lower consistency and often leads to a knock-back.

Another weakness is that PHP's function names are case-insensitive. While this is not a serious drawback, some programmers may find this feature annoying.

However, I do have doubts about the PHP object model. PHP is not specifically designed as an object-oriented language. Some of these features are added later-although it is important to note that you maintain back compatibility with PHP 3, the characteristics of both models remain somewhat. In fact, many of these weaknesses in PHP 5 have been addressed. Please keep an eye on it.

The lack of PHP in some areas makes it quick to make up for what's in the field of expertise. The price is reasonable, so you don't need to worry about licensing issues. It is also open source, so the entire community will pay close attention to the development process: discovering errors and fixing them. If you have an attribute that you do not like, then you can modify the code. In addition, PHP can be naturally combined with Apache: it can be compiled as a module, or compiled directly into Apache binaries.

But running on Apache means that with PHP, you can leverage your investments on any server, because Apache can run on Windows, Linux, Solaris, and a variety of other Unix platforms. In addition, using a Web server that has Apache tracking records means that security is kept to the highest priority. Finally, PHP has a smaller code path, which means less parsing and execution of PHP page server-side code, which results in more efficient memory and usage and faster operation.

What are the new features in PHP 5?

The 4th beta version of PHP 5 was launched at the end of December 2003, and the change log clearly shows that many errors have been identified and eliminated. While it is still being tested, all of its new features and advances are indeed noteworthy.

The main new achievement of PHP 5 lies in its exception handling and a new object, which is introduced into the new object to give PHP real OOP. Exception handling is undoubtedly one of the most significant flaws in PHP 4, and the introduction of exception handling by PHP 5 is undoubtedly a ripe sign. Exception handling means that you have a language-defined and standardized approach to error handling in your software. Just use the try, catch, and throw methods, and your PHP code becomes more robust and concise.


Class Blue {

function OpenFile ($inFile) {
if (file_exists ($inFile)) {
# code to open the file here
} else {
throw new Exception
("Cannot open file: $inFile");
}
}
}

$BLUEOBJ = new Blue ();

try {
$BLUEOBJ->openfile ('/home/shull/file.txt ');

} catch (Exception $myException) {
echo $myException->getmessage ();

# Rest of exception handling code here
}

# Rest of Blue methods here

?>



The new object model has many positive implications for programs written in PHP. In PHP 4, when you pass an object to a function or method, it is passed by value-unless you explicitly tell PHP otherwise. This process means that you must copy a copy of the object (all the data structures in memory). This step uses memory to make access slow and congested. In PHP 5, objects are typically passed by reference.

New object-oriented features in PHP 5, including constructors and destructors, deserve attention. As with C + + and Java, they provide a standard way to create objects, allocate memory, and perform any necessary settings through a constructor method, and perform cleanup through a destructor method.

PHP 5 also introduces finer control over the methods and variables in the class. In PHP 4, everything is public: You can access variables in your class from outside the class or in an inherited class. In PHP 5, you can still make variables or methods public, but you can also make them private so that they can only be used in the class itself. They can also be protected, which means that methods and variables can be viewed within a class or in subclasses.

In addition, PHP 5 introduces type hints or better type checking. When you pass an object to a routine, PHP checks to see if it is the correct type and produces a type mismatch error when the check fails.

Because there are other features, such as static methods and variables, and abstract classes, be sure to review the documentation for more information.

(not to be continued)
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.