PHP, ASP, and ASP. NET_PHP tutorials for dynamic website web development

Source: Internet
Author: User
Tags odbc connection php example
Dynamic website web development PHP, ASP or ASP. NET. This is a frequently asked question, and it is easy to bring people into the debate about Linux or Windows. This debate actually reflects the fact that this is a frequently asked question about competing Web development technologies, and it is easy to bring people into the debate about Linux or Windows. This debate actually reflects how difficult it is to conduct parallel analysis on competing Web development technologies, this difficulty is also greatly increased because developers have different opinions on any comparable operating systems.

So instead of continuing to participate in such a debate, we should look at the advantages of each technology for specific Web development and runtime environments. Although ASP and PHP are more similar than any of them, we still need to discuss ASP. NET. The reason is that developers often confuse ASP with ASP, and with Microsoft's efforts, ASP. NET will indeed replace ASP in the future.

Basic theory-Overview of features
PHP -- Hypertext Pre-processor)
PHP is an open-source scripting language on the server, which is similar to the C language in syntax. Although originally designed for Linux-based Apache Web server systems, PHP has been transplanted to any operating system and compatible with any standard Web server software. From this, we can also find three major advantages of PHP. First, it is a cross-platform technology, so PHP applications can be easily transplanted-of course, it depends on additional components that need to be integrated, such as the vendor-specific database. This portability also brings another advantage, that is, most Web host providers support PHP, so it is very convenient to change the host as needed.

Second, because PHP has many similarities with the C programming language, for developers who are familiar with the relevant syntax, PHP is very easy to use-this syntax is also applied in Java, JavaScript, and Perl. Third, because it is an open-source product, PHP will continue to develop rapidly. More importantly, related vulnerability patches will be implanted into the core library on a regular basis for free.

In addition, under some specific programming needs, PHP is more attractive to developers. First, PHP has an internal database to support direct creation of images and PDF documents and related operations. This means that when an application calls a dynamically created menu image containing the anti-aliased text, or needs to export a page in Acrobat format, PHP will be an ideal technology to solve this problem. Although these functions can also be obtained theoretically through other technologies competing with PHP, other technologies often require third-party custom components to be installed.

Another point that makes PHP the best choice for writing server scripts is that PHP performs well when dealing with problems such as connecting to mySOL or IPVs databases. Although access to the mySOL or IPVs database can be achieved through the ODBC Connection through ASP technology, this usually requires additional configuration by the system administrator. Fortunately, this restriction has been corrected in ASP. NET. when you need to establish a direct database connection similar to using ms SQL Server, you can provide data through mySQL.

ASP-dynamic service page (Active Server Pages)
Microsoft Introduces ASP to Windows NT Server 4 and uses it as the default platform for dynamic Web applications under the IIS Web Server. Because it uses VBScript (a branch of Visual Basic), ASP is immediately sought after by developers familiar with Microsoft IDE-Visual Studio programming. With the continuous development of scripting language, the researchers did not introduce too many functions to ASP to join the technical competition. Therefore, the various image operations and other functions that can be seen in PHP are not integrated into ASP. However, developers can still write (or install) third-party COM objects in the form of DLL files to do similar work. With the server's own permission, you can write code to complete any action. Of course, the defect is that, in order to configure these services, developers have to interact with the desktop system-this feature is not necessary for Web developers.

The advantage of ASP is that Microsoft servers are almost everywhere in the enterprise environment. In addition, ms SQL Server also has a broad market and supports ASP (which is not surprising ). Although in fact, ODBC can be compatible with any data source, SQL Server and file DSN access can be implemented at the code level.

ASP. NET
The debate on choosing ASP or PHP is becoming increasingly redundant with the rise of. NET. Indeed, the debate over the past few years will end with the announcement of the answer to the choice of Java or. NET technology (or both. ASP and ASP. NET use VBScript. For. NET alone, it can use VBScript and about 20 other languages.

For ASP and PHP, ASP. NET is considered another language because it runs on a completely different architecture. The former is the translation script language, while. NET is the compiled framework. This means that the running speed of the web page will be greatly improved first. At the same time, the source code is safer and more robust. In addition, ASP. NET brings a new idea to Web programming-the idea of "code-behind Page. According to the code-behind idea, every HTML page is driven by compiled procedural commands. Therefore, HTML, or the presentation layer, is largely separated from the business logic of the application. Although such separation can also be implemented through PHP and ASP, it is a major part of its own technology, just like ASP. NET.

Another advantage of ASP. NET is that it fully integrates various support for XML and Web services. For. NET, a wide range of security and password system libraries can be used, which is especially useful for financial institutions and enterprise data applications. In terms of defects, even experienced developers may find that using. NET may confuse themselves. Without considering how familiar developers are with the programming languages they use, a significant increase in the difficulty of Program examples may become a major obstacle for Web developers to integrate into ASP. NET. For ASP. NET applications, hosts are also a problem. ASP. NET is not widely supported by host providers like ASP or PHP and cannot compete at the same level.

Practice-language comparison
Variable Declaration


In VBScript (both ASP and ASP. NET use VBScript), you do not have to declare a variable before using it, although this is usually recommended in technical documents. With Option Explicit declaration, developers can use programs to force variable declaration. In PHP, variables can be declared, although there is no way to force developers to do this. Indeed, variables are automatically declared before use. The advantage of PHP variables is that variables can be set to references of other variables. in VBScript, variables can only be defined by values.


<%

'Vbscript Example

Option Explicit

MyVar = 1

Mythervar = myVar

MyVar = 2

'Myresult will be 3

MyResult = myVar + mythervar

%>

// PHP Example

$ MyVar = 1;

'Use the ampersand to make a reference

$ Mythervar = & $ myVar;

$ MyVar = 2;

// $ MyResult will be 4

$ MyResult = $ myVar + $ mythervar;

?>


Variable collection
The methods for using forms and query string variables in PHP and ASP are very similar. There are many ways to access the collection of forms and query string variables, such as using name or using it as an array. In ASP. NET, there are many differences, especially for form fields. Unlike blindly searching for submitted Form variables, code-behind can be familiar with every form field on the HTML page, you can also trigger a check on the values of these form fields based on the execution of any known events. One of the events is "postback". This event is triggered when the form is submitted by the user. Other events can be client programs and can be triggered using JavaScript. ASP. NET has no difference in nature.


<%

'Asp Example

MyFormVal = request. form ("myInputField ")

MyQSval = request. querystring ("myQSitem ")

MyVal = request. item ("myFormOrQSitem ")

%>

// PHP 4.1 + Example

$ MyFormVal = $ _ POST ['myinputfield'];

$ MyQSval =$ _ REQUEST ['myqsitem '];

// PHP 3 + Example

$ MyFormVal = $ HTTP_POST_VARS ['myinputfield'];

// If register_globals = on

$ MyVal = $ myFormOrQSitem;

?>

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.