On PHP and. Net which is more promising

Source: Internet
Author: User
Tags diff oracleconnection what php hosting web hosting web hosting services what is asp
On PHP and. Net which are more promising

On PHP and. Net which are more promising
April 10, 2011
In the long term, or PHP, at present more than 90% of the large-scale portal stations are using PHP development (such as: Sina, Baidu, Huajun, Xinhua, China Network), PHP is free, open source, cross-platform, he and the free Mysql,apache is called the gold combination.
Assuming you haven't decided to use PHP yet, I can assert that PHP's advantages far outweigh its weaknesses. (See the Summary in Table 1.) These benefits boil down to price, speed and efficiency, security, cross-platform applicability, and open source opportunities. Its only weakness is the lack of a pure and perfect OOP implementation, but this is a small drawback. Although the language structure does help, good coding is ultimately brought about by practice, execution, good habits and norms.
PHP Advantage-Comparison between PHP and 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:
  
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)-The database dependencies will be your real goal, as this 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-they can 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 were added later-although it is important to keep back compatibility with PHP 3, the features 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.
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.
Security comparison
ASP. NET official requires that you use IIS. Unfortunately, the history of IIS's vulnerability has been long-standing, which makes many administrators reluctant to deploy it to handle WEB sites. These weaknesses are due to Microsoft's flaws or because IIS is the target of hackers ' attacks: these systems have a history of being hacked or hacked. PHP is also running on Apache, Apache is fast and open source, and has a good security record. Also, as I mentioned, Apache can run on many platforms.
If you're thinking about ASP, but you want to use Apache as your Internet portal, you're lucky to have some choices. First, you can use Apache to forward requests to IIS running internally on another computer. Apache then processes the static content and delivers the ASPX content to the IIS server (not exposed to the Internet).
However, if you want to use Apache to host ASP. NET, there are a few options that Microsoft may or may not support. As a last option, there is Ximian Project Mono, which is dedicated to building an open source module. Please browse the www.go-mono.com for more information.
Database Encoding Example
One of the first things to consider when you choose PHP or ASP is to connect to the database. However, it is more complex to take advantage of ASP because you can select any language from many alternative languages. Of course, these code examples will have to be embedded in HTML pages, instantiated classes, and so on. However, the following information will give you an idea of the coding style of both.
PHP 5 Connection to Oracle
The following is a PHP 5 class that provides an oracle connectivity and disconnection routine that demonstrates a way to connect with Oracle using PHP 5, which can also use other drivers (such as ODBC drivers) and a common Database interface:
Class Oracle_object {
protected $theDB;
protected $user;
protected $pass;
protected $db;
function __construct ($u, $p, $d) {
$this->user = $u;
$this->pass = $p;
$this->db = $d;
}
function Db_open () {
$theDB = @OCILogon ($this->user, $this->pass, $this->db);
Db_check_errors ($php _errormsg);
}
function Db_close () {
[Email protected] ($theDB);
Db_check_errors ($php _errormsg);
}
function __destruct () {
Print ("So long ...");
}
}
ASP. NET to Oracle connection
If you want to take advantage of VB. NET (Visual Basic is Microsoft's default. NET programming language) connect with Oracle, so take a look at this example from MSDN:
Imports System
Imports System.Data
Imports System.Data.OracleClient
Imports Microsoft.VisualBasic
Class Sample
Public Shared Sub Main ()
Dim oraconn as OracleConnection = New OracleConnection
("Data source=myoracleserver;integrated security=yes;")
Dim oracmd as OracleCommand = New OracleCommand
("Select customer_id, NAME from DEMO. CUSTOMER ", Oraconn)
Oraconn.open ()
Dim myreader as OracleDataReader = Oracmd.executereader ()
Do while (Myreader.read ())
Console.WriteLine (VbTab & "{0}" & VbTab & "{1}",
Myreader.getint32 (0), myreader.getstring (1))
Loop
Myreader.close ()
Oraconn.close ()
End Sub
End Class
Make a choice
Assuming you haven't decided to use PHP yet, I can assert that PHP's advantages far outweigh its weaknesses. (See the Summary in Table 1.) These benefits boil down to price, speed and efficiency, security, cross-platform applicability, and open source opportunities. Its only weakness is the lack of a pure and perfect OOP implementation, but this is a small drawback. Although the language structure does help, good coding is ultimately brought about by practice, execution, good habits and norms.
Comparison between PHP and ASP.
Table 1
PHP 4 PHP5 ASP.
Free Free Free software price
Free $$ Free Platform price
Speed Strong strength
High efficiency and strength
Security Qiangqiangqiang (Microsoft Company is too strong, tall tree catches. The history of IIS being attacked is also very early.
Platform strength (for IIS only)
Any arbitrary Win32 platform (for IIS only)
Source code disclosure is whether
Exception No Yes Yes
OOP weak
Price
Here, we should not simply consider the initial investment-this is obviously free for PHP-it should also consider the cost of implementation, maintenance, and commissioning. For PHP, you may need to purchase the Zend optimization engine. With ASP, however, you'll invest from the start, and you'll pay for additional technology-for example, a library that performs graphics processing. However, in the long run, PHP will not force you to upgrade and charge you more license fees. Everyone who has approached a complex license knows that many companies spend a lot of time and money just to ensure compliance. Also, when you get a bug fix, you get a different response. This will of course translate into time, and time will turn into the cost of overall development.
Speed and efficiency
As I mentioned earlier, ASP. NET is a framework that allows you to use a variety of programming languages. In addition, it allegedly has an excellent object-oriented model. Although all of this is true, it is unfavorable in the light of speed. For these reasons, running an ASP page in ASP. NET requires more code than running an equivalent PHP page in the PHP engine. PHP is a "fast-rough" solution and is a solution designed to do the job. Although many of the robustness has been enhanced since version 2.0 and 3.0, it still retains the core optimization of the high-speed approach.
Speed is not the only factor to consider. Memory utilization is also important.
Security
ASP. NET is running on IIS, and IIS has been attacked countless times-as confirmed by the IT News report every other week. It has become such a burden that, in fact, many IT pros still refuse to use the IIS Web server to open their networks, despite the huge cost of sales promotion. While PHP uses Apache. Apache has a proven track record of speed, reliability, and robust security. Please browse the www.securityfocus.com for more information.
Cross-platform applicability
ASP. NET runs on IIS and starts running on Apache (Apache can run on many platforms). PHP has been designed to work with Apache from the start, so you have a number of proven and reliable server platforms to choose from.
Open Source Opportunities
Open source is not only done by whimsical programmers or companies that want to save some license fees. Open source can be a true godsend when you are dealing with errors in the software itself.
In the case of PHP or ASP, you will have a large user base, they use the software and may encounter errors. With ASP. NET, these errors must be notified, repaired, tested, and eliminated in a new patch or version through an official program. However, PHP patches can be patched and released quickly. Anyone who has witnessed open source development knows that new versions and patches are usually rolled out within a few weeks or months, rather than as commercial software. If this is not fast enough, you can usually fix the problem yourself (if necessary).
The advantages of PHP in the field of web development
Your current location: Du demon---technical documentation in the eyes of most web developers, ASP and JSP are considered to be the front-runners, while PHP is considered a weak "struggling", or it is a language that is devalued to the amateur, not worth participating in enterprise Web Development competition. In my opinion, the reason PHP is not considered a competitor is that the reviewer lacks knowledge of it and does not know about other operating systems for Web development. Contrary to some ideas, windows no longer occupies the largest share of the web hosting services market, and I suspect it is also being pulled out of the city in the area of web development.
Why is there no PHP in enterprise development?
Obviously, PHP is considered to be behind ASP and JSP too much, so that it is useless, but this is exactly the same as the fact. PHP is a powerful language in itself. It's actually on every Linux distribution, and also on Mac OS X. It is free to get the artifact (Building-block) tools and software that develop and use PHP code. The Commercial integrated development environment for developing PHP applications (commercial INTEGRATED development environments, IDES) can also find such tools as Komodo (which runs on Linux and Windows) and Zend STUDIO (this application can be run on any operating system with a Java Runtime Environment). The fact that you can run PHP-built sites on almost every web hosting, rather than taking into account what operating system the server is running, makes PHP more appealing.
What can PHP offer?
Forget about what's going on around PHP for a while, and consider what PHP can offer. It is a robust server-side language that provides a considerable amount of functionality and can quickly serve the page.
Easy to use
Any user who uses C or Perl or another language with similar styles and syntax can quickly get started with PHP. Although it is designed to be used on the web, it can also be used as a command-line language. Does the Web application you are writing need to execute some code every hour or every day? Using cron or a similar scheduling manager, you can plan to schedule PHP code to execute when you want it to, and use normal commands to interpret scripts or batch files to execute such code. You do not need to automatically invoke a browser to view a dedicated webpage to execute your event, or rely on a visitor's click to tell your system that a particular code needs to be executed at a particular time. The fact that PHP is extensible in this area is absolutely appealing.
Benefits of PHP
I am not a JSP or an ASP veteran, and I do not want to belittle these languages here. Instead, I'll focus on the benefits of PHP.
Localization
PHP allows you to provide localized services to visitors to your site. When a user clicks into the site, the site automatically provides the page in their native language based on their browser settings. To do this, you do not need to use the chores file for language translation, but rather the same ability to use and localize the C program, implemented through a system called GetText. If the requested language file exists, then the text that the user sees is the native language, and if the language file does not exist, then the text is the default English or any other language that you specify. Many localized UNIX applications use GetText as a standard, making it easy for third-party translators to translate.
Easy to use command line
PHP supports setting up and executing command-line programs where needed. Using the standard UNIX diff tool, it can generate errors between the last modification and the current comment that is to be sent to the wrong owner using e-mail. The PHP code performs a diff on the two files written on the system and regenerates the output as input into an e-mail message to be sent. This email is sent by PHP on its own.
Other benefits
The above is only two of the powerful features I use in my own program, but also other functions. For example, you can:
Create simple Flash animations on the fly.
Create PDF documents instantly.
Use advanced math features, as well as object-oriented programming techniques.
Read and write to local and IMAP mailboxes.
Any standard Internet protocol can be used in PHP. Want to write a PHP-based FTP, Web, or news client? No problem! Using PHP alone, you can create your own protocol by writing clients and servers that use standard TCP/IP sockets.
Enables support for encryption and support for various database servers.
Short-sighted commentary
I think those who are looking for top-notch web development languages to get rid of PHP are extremely sighted. I've been writing code in PHP for many years, whether it's advanced features like the bug tracker, or simply reusing common features like headers and footers, which I've written in PHP. I use PHP to write more than half of static pages, but also write a full-featured multimedia presentation. I'm not the only one who uses PHP. If PHP is not worth noticing, if it's just a pediatric or hobbyist language, why is it the fastest growing language in Web development? If it's not as powerful as an ASP or JSP, why would it be used in traffic-heavy web sites? Yahoo, for example, is said to be built by PHP.
Developers are accustomed to using familiar products
I'm sure the ASP and JSP have their strengths, but I believe people use them not because they can provide more powerful functionality than PHP, but because people already know them and want to write code in their own way. Excluding PHP can only represent ignorance of the language.
The above points of view are somewhat biased.
Since ASP. NET introduces the programming model of ASP. So the speed comes up, and the quality comes up, but the threshold for programming is high,
PHP is easy to get started so Microsoft may be very supportive, from Microsoft's new Web platform can be seen
If it is a beginner's recommendation to learn ASP, because this technology although a bit outdated, but after learning to turn. NET or PHP is not difficult
If you have a programming foundation or a person who has confidence in Microsoft or pursues the path of agility, you can learn. NET
If you are a pursuit of executive efficiency, open and popular with people who can learn PHP
  • 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.