Comparison: equivalent relationship between php and asp objects

Source: Internet
Author: User
: This article mainly introduces the comparison: the equivalent relationship between php and asp objects. if you are interested in PHP tutorials, refer to it. 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 );

The translation above is not good. please forgive me!


The above is a comparison: the equivalent relationship between php and asp objects, including the object content, hope to be helpful to friends who are interested in PHP tutorials.

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.