PHP with ASP.NET

xiaoxiao2021-03-05  28

From: CCID

You have many options when you mention Web development. Many of these methods involve pretreatment - that is, embedding the code into the HTML page using a specific tag, tells the pre-processor, which contains code and should be processed. It is very similar to the CGI, which runs on the server and returns some content, which is manifested as part of the results of the HTML page that is sent back to the browser. Open Source Scripting Language PHP and Microsoft ASP.NET Framework is this type; JavaServer Pages (JSP) and Perl / Mason also run in this way. In this article, I will focus on PHP - Oracle has chosen the technology that merges into its product - and ASP.NET. I will outline the various advantages and weaknesses of the two and focus on which technological factors that will help you determine the development project should choose. There are many factors that need to be considered, and different projects may resort to different technologies. In summary, you will see the advantages of price, speed and efficiency, security, cross-platform support, etc., as well as the advantages of open source solution solutions. What is ASP.NET? The latest version of the ASP is not completely compatible with the early version of the ASP because the software has been overwritten. Early ASP technologies are actually more common to PHP more than the common point of ASP.NET, and ASP.NET is a complete framework for building a web application. One of the main features of this model is to select the flexibility of the programming language. ASP.NET can use scripting languages ​​(such as VBScript, JScript, Perlscript, and Python), and compiled languages ​​(such as VB, C #, C, COBOL, SMALLTALK, and LISP). The new framework uses the universal language to operate the environment (CLR); first compile the source code from your language into a Microsoft intermediate language code, then the CLR executes these code. This framework also provides true object-oriented programming (OOP) and supports real inheritance, polymorphisms and packages. The .NET class library organizes the inheritable class based on a particular task (eg, using XML or image processing). In addition to programming languages ​​and methods, database access is also a factor. When you program with ASP.NET, you can use ODBC to integrate databases; ODBC provides a group of consistent call functions to access your target database. The advantages of advantages and weakness ASP.NET are obviously in its simple design and implementation. This is the dream of object-oriented programming person: the language is flexible and supports complex object-oriented features. In this sense, it can truly interoperate with the programmers existing skills. Another advantage of ASP.NET is its development environment. For example, developers can use WebMatrix (tools for a community support), Visual Studio .NET, or a variety of Borland tools (such as Delphi and C Builder). For example, Visual Studio allows setting breakpoints, tracking code segments, and viewing call stacks. All in all, it is a complex commissioning environment. Many other third-party ASP.NET IDE solutions will also have emerged. But you have got a strong property, it will cost the loss efficiency. ASP.NET spends very large in memory usage and execution time, which is attributed to a longer code path. For web-based applications, these limitations may be a serious problem, because on the web, your application may expand to thousands of users per second. Memory usage may also become a problem on the web server. What is PHP? PHP is a scripting language based on the pretreatment HTML page model.

When the PHP preprocessor in the web server finds that the PHP engine is called to execute the code:

Some Code Here

?>

Any programmers who use ordered programming languages ​​will be very familiar with PHP; you will find it similar to Perl, C and Java in syntax. Strictly speaking, Java is an ordered programming language, but it also uses object-oriented structures and concepts. PHP draws on this structure when it is suitable, but it is not a pure OOP language. In the discussion of ASP.NET, I mentioned the ODBC driver and how to build an application in consideration of database abstraction. In PHP, you can also use ODBC with database dialogue, so you have a series of supported databases available. There are also mysql, oracle and postgres native drivers. In addition, if you want to use Oracle, a special OCI8 library will provide more access to Oracle, allowing you to use features such as LOB, BLOB, Clob, and Bfile. At this time, you may ask "Why is the database related to the database be called PHP?" Database abstraction or independence is that you try to build multiple databases or need to be transplanted between databases (for example, from development to commissioning A factor to consider when porting the application. And these really should be careful and considered. But as Tom Kyte is pointed out in his new book - Effective Oracle By Design (Oracle Press), database relevance will be your true goal, because this will maximize your investment in this technology. If you are general access to Oracle - via ODBC or Perl DBI library, you will not be able to use other databases without feature. In addition, optimization queries are different in each database. Zend Technologies is a commercial software company that makes a significant contribution to PHP. It created a commercial development environment called Zend Studio, which contains a complex debugger, a monitors, and other features. The company also built a free Zend Optimizer, which combined with Zend Encoder compiled PHP code to improve performance. There are other commercial products, such as Zend Performance Suite, which can cache pre-compiled PHP pages to further improve overall performance. Advantages and weaknesses to beta 4, PHP 5 still have some shortcomings, including missing abnormalities and event-based error handling routines - they can interrupt the normal program stream and turn the code to a special error handling section. Java also provides an exception for error handling, while C provides exception handling through TRY, CATCH, and THROW syntax. Of course, you can still manage errors in PHP, but its structure is not standardized, thus making programmers must use their own tools to determine how to perform errors, which will lead to lower consistency and often lead to backwards. Another weak point is the function name of PHP is not case sensitive. Although this is not a serious shortcoming, some programmers may feel that this feature is annoying. However, I did doubt about the PHP object model. PHP is not specifically designed as an object-oriented language. Part of these characteristics is later added - although pay attention to maintaining backward compatibility with PHP 3, there are some characteristics of both models. In fact, many of these weaknesses in PHP 5 have been resolved. Please pay attention. PHP is missing in some fields, which will quickly make up in the field of good at the field. The price is reasonable, so you don't need to worry about the license. It is also open source, so the entire community will pay close attention to the development process: find errors and fix them.

If you have a feature, you don't like it, then you can modify the code. In addition, PHP can be combined with apache: it can be compiled as a module, or directly compile into an Apache binary. But running on Apache means that using PHP, you can take advantage of you already invested any server, because Apache can run on Windows, Linux, Solaris, and a variety of other UNIX platforms. In addition, web servers using trace records with Apache means that security can be kept at the highest priority. Finally, PHP has a smaller code path, which means less analysis and executing PHP page server-side code, which will bring more efficient memory and usage and faster run. What features have been added to PHP 5? The fourth bettion of PHP 5 is launched by the end of December 2003, and the change log clearly shows that many errors have been found and has been eliminated. Although it is still testing, all of its new features and progress are indeed worthy of attention. The main new achievement of PHP 5 is its exception handling and a new object, and this new object introduces the characteristic gives PHP real OOP. Abnormal processing is undoubtedly one of the most prominent shortcomings in PHP 4, and PHP 5 introduces an exception handling is undoubtedly a mature sign. Abnormal processing means that you have a standardized error handling method in your software. Simply use try, catch, and throw methods, your PHP code becomes stronger 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 brings many positive impacts for programs written in PHP. In PHP 4, when passing an object to a function or method, it is passed through a value-unless you still explicitly inform PHP. This process means that a copy of the object must be copied (all data structures in memory). This step uses memory so that accesses slow down and congestion. In PHP 5, it is usually transmitted by reference. New object-oriented properties (including constructors and sectors) in PHP 5 are worthy of attention. As with C and Java, they provide a standard method that creates objects, assigns memory and executes any necessary settings through a constructor method, and performs cleaning through a paratic device method. PHP 5 also introduces more fine control of methods and variables in the class. In PHP 4, everything is public: You can access the variables in your class or in the inheritance class. In PHP 5, you can still make variables or methods are public, but you can make them private, so that they can only be used in the class itself. You can also protect them, that is, you can view methods and variables within the class or in subclasses. In addition, PHP 5 introduces a type prompt or a better type of check. When you pass an object to a routine, PHP can check if it is the correct type and generates a type does not match when the check fails. Since there are other features (such as static methods and variables and abstract classes), be sure to view the document for details.

Safety compares ASP.NET officially requires you to use IIS. Unfortunately, IIS is prone to attack history has been long, which makes many administrators who are reluctant to deploy it to handle web sites. These weaknesses are because Microsoft's defects or because IIS is the target of hackers attacks. These systems have a history of being black or attacked. PHP is also running on Apache, Apache is fast and is open source, and has a good security record. In addition, as I mentioned, Apache can run on many platforms. If you are considering ASP.NET, but you want to use Apache as an Internet portal, so lucky you can have some choices. First, you can use Apache to forward the request to IIS running inside another computer. The Apache then processes static content and transmits the ASPX content to the IIS server (not exposed to the Internet). However, if you want to use Apache to carry ASP.NET, then provide some options that Microsoft may support it. As the last choice, there is Ximian's Project Mono, which is committed to building an open source module. Please visit www.go-mono.com for more information. Database Coding Sample You first consider the factor in the use of PHP or ASP.NET is the connection to the database. However, using ASP.NET is more complicated because you can choose any language from many alternative languages. Of course, these code examples must be embedded in the HTML page, instantiated class, etc. However, the following information will make you know more about the coding style of both. PHP 5 and Oracle Connections The following is a PHP 5 class, which provides an Oracle connection and disconnect routine to demonstrate the use of PHP 5 (you can also use other drivers, such as ODBC drivers) and general database interfaces) Oracle connection:

Class Oracle_OB; Protected $ User; protected $ pass; protected $ db; function __construct ($ U, $ P, $ d) {$ this-> user = $ u; $ this-> pass = p; $ this-> db = $ d;} Function DB_Open () {$ these-> User, $ this-> pass, $ this-> db); db_check_errors ($ php_errormsg);} function db_close {@Ocilogoff ($ THEDB); DB_CHECK_ERRORS ($ PHP_ERRORMSG);} function __destruct () {Print ("so long ...");}} ASP.NET with Oracle Connection If you want to take advantage of VB.NET (Visual Basic It is the default .NET programming language of Microsoft), then 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.get32 (0), myreader.getstring (1)) loop myreader.close () ORACONN.CLOSE () End Sub End Class makes the choice assume that you have not decided to choose PHP, I It can be asserted that the advantage of PHP far exceeds its weaknesses. (See the summary of Table 1.) These advantages are attributed 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 shortcoming. Although language structure is indeed helpful, good coding is ultimately brought by practical, executive, good habits and norms. Table 1PHP 4 PHP 5 ASP.NET Software Price Free Free Free Platform Price Free $$ Speed ​​Strong Weak Efficiency Strong Strong Strong Strong Strong Platform Strong Weak (IIS) Platform Arbitrary Win32 (for use only IIS) Does it provide source code whether it is not an OOP weak and strong

price. Here, we should not simply consider the initial investment - for PHP, this is obviously free - the cost of implementation, maintenance and debugging should also be considered. For PHP, you may need to purchase the Zend Optimization Engine. However, using the ASP, you will invest in the beginning, and you have to add a library for additional technology - for example, to perform graphic processing. But in the long run, PHP will not force you to upgrade and charge you more licensing fees. Everyone who has exposed to complex licenses know that many companies spend a lot of time and money are only to ensure their compliance. In addition, when you get the wrong repair time, the reaction you get is different. This of course will be converted to time, and time will be converted to 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 is alleged to have an excellent object-oriented model. Although all of this is true, it is unfavorable when considering the speed. Based on the above reasons, run the ASP page in ASP.NET and need to perform more code compared to the PHP engine running equivalent PHP page. PHP is a "rapid rough" solution that is designed to complete the work. Although many robustness has been enhanced since 2.0 and 3.0, it still retains the high speed method of the core.

The speed is not the only factor to consider. Memory usage is also important.

safety. ASP.NET is running on IIS, and IIS has been attacked numerous times - as confirmed by IT news report every week. It has become such a burden, in fact, despite its consuming huge sums of sales promotion, many IT professionals still refuse to open their networks with IIS web servers. PHP uses apache. Apache has a record that has been proved, reliability, and solid security. Please visit www.securityfocus.com for more information. Cross-platform applicability. ASP.NET is running on IIS and starting on Apache (Apache can run on many platforms). PHP is designed to work with Apac from the beginning, so you have many setup and reliable server platforms.

Open source code opportunities. Open source does not rely on some of the whimsical programmers or companies who want to save some licensed costs. When you handle the software itself, open source may become a real day.

In the case of using PHP or ASP.NET, you will have a large user group that uses software and may encounter an error. Using ASP.NET, these errors must be notified, repaired, tested through an official program, and eliminated in a new patch or version. However, the PHP patch can quickly get repaired and released. Anyone who witnesses the development of open source code knows that new versions and patches are usually launched in a few days or within a few days of commercial software. If this is not fast enough, you can usually patch your problem (if necessary).

About author

Sean Hull is an advanced consultant from Iheavy Inc., which is located in New York City. He focused on open source technology and commercial technology (such as Oracle), and has served in a number of successful New York.

Some Code Here

?>

Any programmers who use ordered programming languages ​​will be very familiar with PHP; you will find it similar to Perl, C and Java in syntax. Strictly speaking, Java is an ordered programming language, but it also uses object-oriented structures and concepts. PHP draws on this structure when it is suitable, but it is not a pure OOP language. In the discussion of ASP.NET, I mentioned the ODBC driver and how to build an application in consideration of database abstraction. In PHP, you can also use ODBC with database dialogue, so you have a series of supported databases available. There are also mysql, oracle and postgres native drivers. In addition, if you want to use Oracle, a special OCI8 library will provide more access to Oracle, allowing you to use features such as LOB, BLOB, Clob, and Bfile. At this time, you may ask "Why is the database related to the database be called PHP?" Database abstraction or independence is that you try to build multiple databases or need to be transplanted between databases (for example, from development to commissioning A factor to consider when porting the application. And these really should be careful and considered. But as Tom Kyte is pointed out in his new book - Effective Oracle By Design (Oracle Press), database relevance will be your true goal, because this will maximize your investment in this technology. If you are general access to Oracle - via ODBC or Perl DBI library, you will not be able to use other databases without feature. In addition, optimization queries are different in each database. Zend Technologies is a commercial software company that makes a significant contribution to PHP. It created a commercial development environment called Zend Studio, which contains a complex debugger, a monitors, and other features. The company also built a free Zend Optimizer, which combined with Zend Encoder compiled PHP code to improve performance. There are other commercial products, such as Zend Performance Suite, which can cache pre-compiled PHP pages to further improve overall performance. Advantages and weaknesses to beta 4, PHP 5 still have some shortcomings, including missing abnormalities and event-based error handling routines - they can interrupt the normal program stream and turn the code to a special error handling section. Java also provides an exception for error handling, while C provides exception handling through TRY, CATCH, and THROW syntax. Of course, you can still manage errors in PHP, but its structure is not standardized, thus making programmers must use their own tools to determine how to perform errors, which will lead to lower consistency and often lead to backwards. Another weak point is the function name of PHP is not case sensitive. Although this is not a serious shortcoming, some programmers may feel that this feature is annoying. However, I did doubt about the PHP object model. PHP is not specifically designed as an object-oriented language. Part of these characteristics is later added - although pay attention to maintaining backward compatibility with PHP 3, there are some characteristics of both models. In fact, many of these weaknesses in PHP 5 have been resolved. Please pay attention. PHP is missing in some fields, which will quickly make up in the field of good at the field. The price is reasonable, so you don't need to worry about the license. It is also open source, so the entire community will pay close attention to the development process: find errors and fix them.

If you have a feature, you don't like it, then you can modify the code. In addition, PHP can be combined with apache: it can be compiled as a module, or directly compile into an Apache binary. But running on Apache means that using PHP, you can take advantage of you already invested any server, because Apache can run on Windows, Linux, Solaris, and a variety of other UNIX platforms. In addition, web servers using trace records with Apache means that security can be kept at the highest priority. Finally, PHP has a smaller code path, which means less analysis and executing PHP page server-side code, which will bring more efficient memory and usage and faster run. What features have been added to PHP 5? The fourth bettion of PHP 5 is launched by the end of December 2003, and the change log clearly shows that many errors have been found and has been eliminated. Although it is still testing, all of its new features and progress are indeed worthy of attention. The main new achievement of PHP 5 is its exception handling and a new object, and this new object introduces the characteristic gives PHP real OOP. Abnormal processing is undoubtedly one of the most prominent shortcomings in PHP 4, and PHP 5 introduces an exception handling is undoubtedly a mature sign. Abnormal processing means that you have a standardized error handling method in your software. Simply use try, catch, and throw methods, your PHP code becomes stronger 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 brings many positive impacts for programs written in PHP. In PHP 4, when passing an object to a function or method, it is passed through a value-unless you still explicitly inform PHP. This process means that a copy of the object must be copied (all data structures in memory). This step uses memory so that accesses slow down and congestion. In PHP 5, it is usually transmitted by reference. New object-oriented properties (including constructors and sectors) in PHP 5 are worthy of attention. As with C and Java, they provide a standard method that creates objects, assigns memory and executes any necessary settings through a constructor method, and performs cleaning through a paratic device method. PHP 5 also introduces more fine control of methods and variables in the class. In PHP 4, everything is public: You can access the variables in your class or in the inheritance class. In PHP 5, you can still make variables or methods are public, but you can make them private, so that they can only be used in the class itself. You can also protect them, that is, you can view methods and variables within the class or in subclasses. In addition, PHP 5 introduces a type prompt or a better type of check. When you pass an object to a routine, PHP can check if it is the correct type and generates a type does not match when the check fails. Since there are other features (such as static methods and variables and abstract classes), be sure to view the document for details.

Safety compares ASP.NET officially requires you to use IIS. Unfortunately, IIS is prone to attack history has been long, which makes many administrators who are reluctant to deploy it to handle web sites. These weaknesses are because Microsoft's defects or because IIS is the target of hackers attacks. These systems have a history of being black or attacked. PHP is also running on Apache, Apache is fast and is open source, and has a good security record. In addition, as I mentioned, Apache can run on many platforms. If you are considering ASP.NET, but you want to use Apache as an Internet portal, so lucky you can have some choices. First, you can use Apache to forward the request to IIS running inside another computer. The Apache then processes static content and transmits the ASPX content to the IIS server (not exposed to the Internet). However, if you want to use Apache to carry ASP.NET, then provide some options that Microsoft may support it. As the last choice, there is Ximian's Project Mono, which is committed to building an open source module. Please visit www.go-mono.com for more information. Database Coding Sample You first consider the factor in the use of PHP or ASP.NET is the connection to the database. However, using ASP.NET is more complicated because you can choose any language from many alternative languages. Of course, these code examples must be embedded in the HTML page, instantiated class, etc. However, the following information will make you know more about the coding style of both. PHP 5 and Oracle Connections The following is a PHP 5 class, which provides an Oracle connection and disconnect routine to demonstrate the use of PHP 5 (you can also use other drivers, such as ODBC drivers) and general database interfaces) Oracle connection:

Class Oracle_OB; Protected $ User; protected $ pass; protected $ db; function __construct ($ U, $ P, $ d) {$ this-> user = $ u; $ this-> pass = p; $ this-> db = $ d;} Function DB_Open () {$ these-> User, $ this-> pass, $ this-> db); db_check_errors ($ php_errormsg);} function db_close {@Ocilogoff ($ THEDB); DB_CHECK_ERRORS ($ PHP_ERRORMSG);} function __destruct () {Print ("so long ...");}} ASP.NET with Oracle Connection If you want to take advantage of VB.NET (Visual Basic It is the default .NET programming language of Microsoft), then 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.get32 (0), myreader.getstring (1)) loop myreader.close () ORACONN.CLOSE () End Sub End Class makes the choice assume that you have not decided to choose PHP, I It can be asserted that the advantage of PHP far exceeds its weaknesses. (See the summary of Table 1.) These advantages are attributed 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 shortcoming. Although language structure is indeed helpful, good coding is ultimately brought by practical, executive, good habits and norms. Table 1PHP 4 PHP 5 ASP.NET Software Price Free Free Free Platform Price Free $$ Speed ​​Strong Weak Efficiency Strong Strong Strong Strong Strong Platform Strong Weak (IIS) Platform Arbitrary Win32 (for use only IIS) Does it provide source code whether it is not an OOP weak and strong

price. Here, we should not simply consider the initial investment - for PHP, this is obviously free - the cost of implementation, maintenance and debugging should also be considered. For PHP, you may need to purchase the Zend Optimization Engine. However, using the ASP, you will invest in the beginning, and you have to add a library for additional technology - for example, to perform graphic processing. But in the long run, PHP will not force you to upgrade and charge you more licensing fees. Everyone who has exposed to complex licenses know that many companies spend a lot of time and money are only to ensure their compliance. In addition, when you get the wrong repair time, the reaction you get is different. This of course will be converted to time, and time will be converted to 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 is alleged to have an excellent object-oriented model. Although all of this is true, it is unfavorable when considering the speed. Based on the above reasons, run the ASP page in ASP.NET and need to perform more code compared to the PHP engine running equivalent PHP page. PHP is a "rapid rough" solution that is designed to complete the work. Although many robustness has been enhanced since 2.0 and 3.0, it still retains the high speed method of the core.

The speed is not the only factor to consider. Memory usage is also important.

safety. ASP.NET is running on IIS, and IIS has been attacked numerous times - as confirmed by IT news report every week. It has become such a burden, in fact, despite its consuming huge sums of sales promotion, many IT professionals still refuse to open their networks with IIS web servers. PHP uses apache. Apache has a record that has been proved, reliability, and solid security. Please visit www.securityfocus.com for more information. Cross-platform applicability. ASP.NET is running on IIS and starting on Apache (Apache can run on many platforms). PHP is designed to work with Apac from the beginning, so you have many setup and reliable server platforms.

Open source code opportunities. Open source does not rely on some of the whimsical programmers or companies who want to save some licensed costs. When you handle the software itself, open source may become a real day.

In the case of using PHP or ASP.NET, you will have a large user group that uses software and may encounter an error. Using ASP.NET, these errors must be notified, repaired, tested through an official program, and eliminated in a new patch or version. However, the PHP patch can quickly get repaired and released. Anyone who witnesses the development of open source code knows that new versions and patches are usually launched in a few days or within a few days of commercial software. If this is not fast enough, you can usually patch your problem (if necessary).

About author

Sean Hull is an advanced consultant from Iheavy Inc., which is located in New York City. He focused on open source technology and commercial technology (such as Oracle), and has served in a number of successful New York.

转载请注明原文地址:https://www.9cbs.com/read-32169.html

New Post(0)