Equivalent relationship between PHP and ASP objects [zz]

Source: Internet
Author: User
Http://www.ttud.com/info/1661.htm
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 );

Related Article

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.