Equivalent relationship between php and asp objects

Source: Internet
Author: User
: This article mainly introduces the equivalent relationship between php and asp objects. For more information about PHP tutorials, see. 1) output 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) redirect address
Asp: Response. Redirect (newurl)
Php: Header ("Location: $ newurl ");

4) Cookie processing
Asp: Response. Cookies (cname) = newval
Val = Request. Cookies (cname)

Php: setcookie ($ cname, $ newval );
$ Val = $ HTTP_COOKIE_VARS [$ cname];

5) application variable
Asp: Application (appvarname)
Php: This variable is not provided and can be simulated using other methods, such as databases.

6) session variables
Asp: Session (sessionname) = newval
Val = 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 ('Val ');
$ Val = 88;
Session_start ();
Print $ val;

7) Form variable
Asp: Request. Form ("fval ")
Request. QueryString ("fval ")

Php: $ HTTP_POST_VARS ["fval"];
$ 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.

10) cache buffer
Asp: Response. Buffer = true
Response. Write ("aaa ");
Response. Flush ()
Php: ob_start ();
Print "aaa ";
Ob_end_flush ();

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

Php: seconds:
Set_time_limit (360 );


If any errors occur, please kindly advise.



The above describes the equivalent relationship between php and asp objects, including the relevant content, and 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.