Examples show some similarities between ASP and PHP

Source: Internet
Author: User
Tags what is asp
What is ASP? ASP is short for ActiveServerPage. It is a web page that contains the code of the VBScript or Jscript script program.

What is ASP?

ASP is the abbreviation of Active Server Page. It is a web page that contains the code of a Script program using VB Script or Jscript. When the browser browses ASP Web pages, the Web server will generate the corresponding HTML code based on the request and then return it to the browser, so that the browser can see the dynamically generated Web page. ASP is an application developed by Microsoft to replace CGI script programs. it can interact with databases and other programs. It is a simple and convenient programming tool. After learning the basic syntax of VBSCRIPT, you can easily compile your own ASP system by knowing the usage, attributes, and methods of each component. The format of ASP webpage files is. ASP.

What is PHP?

PHP is a server-side HTML-embedded script description language. Its strongest and most important feature is its database integration layer. using it to complete a web page containing database functions is incredibly simple. In HTML files, PHP scripts (similar to Perl or c) can be referenced using special PHP labels, so that the web page creator does not have to rely entirely on HTML to generate webpages. Because PHP is executed on the server side, the client cannot see the PHP code. PHP can complete any task that CGI scripts can do, but its function depends on its compatibility with various databases. In addition to HTTP communication, PHP can also use the IMAP, SNMP, NNTP, and POP3 protocols.

1) write HTML
Asp: Response. Write (str)
Php: print $ str;
Echo $ str;
Print_r $ debug_str;

2) Form, Cookie and QueryString variable
Asp: you can use Request object.
Php: these variables are automatically provided as a global variable, if configured in the PHP. ini file as follows:

Variables_order = "EGPCS"
Register_globals = On

For security, I will not allow register_globals (set it to OFF). then the variable is only used in the array:
$ HTTP_POST_VARS, $ HTTP_COOKIE_VARS and $ HTTP_GET_VARS.

3) Redirecting to another location
Asp: Response. Redirect (url)
Php: Header ("Location: $ url ");

4) Cookie processing
Asp: Response. Cookies (cookiename) = newval
Avar = Request. Cookies (cookiename)

Php: setcookie ($ cookiename, $ newval );
$ Avar = $ HTTP_COOKIE_VARS [$ cookiename];

5) Application variable
Asp: Application (appvarname)
Php: No. it can be simulated using a database.

6) Session variables
Asp: Session (sessionname) = newval
Avar = Session (sessionname)

Php: in PHP4 or later versions, we determine that the variable is used as a session in
Session_register ($ sessionname). then, we call session_start ()
Resume the session variable value on the. php page.

For example:

Session_register ("avar ");
$ Avar = 99;
Session_start ();
Print $ avar;
7) Form variable
Asp: Request. Form ("formvar ")
Request. QueryString ("getvar ")

Php: $ HTTP_POST_VARS ["formvar"];
$ HTTP_GET_VARS ["getvar"];

The GET and POST variables can be automatically modified to the PHP variables alternately, which is unsafe.

8) Server variables
Asp: There are many server variables. you can refer to the ASP document for an example:

Request. ServerVariables ("HTTP_HOST

Php: As the ISAPI mode, server variables are stored in the $ HTTP_SERVER_VARS array.
As CGI, they are stored in environment variables, using the $ HTTP_ENV_VARS array or getenv ()
. Example:

$ HTTP_SERVER_VARS ["HTTP_HOST"] using ISAPI module

$ HTTP_ENV_VARS ["HTTP_HOST"] using CGI module

9) database access
Asp: ado technology
Php: ADO can be simulated using the adodb Library, which is equivalent to ado.
The limit is that read-only and roll-forward cursors are currently supported.
(Annotation) you can also directly call the com Library to view my article.

10) Buffering
Asp: Response. Buffer = true
Response. Write ("abc ");
Response. Flush ()
Php: ob_start ();
Print "abc ";
Ob_end_flush ();

11) Script Timeout
Asp: seconds:
Server. ScriptTimeout (240)

Php: seconds:
Set_time_limit (240 );

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.