The equivalence relationship between PHP and ASP objects

Source: Internet
Author: User
Tags php tutorial
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 provided automatically as a global variable, if configured in the php.ini file:

Variables_order= "Egpcs"
Register_globals=on

For security, I will not allow register_globals (set it to off). The variable is then used only 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 emulated in other ways, such as a database

6) Session Variable
Asp:session (sessionname) = newval
Val= Session (sessionname)

PHP: In PHP4 or later versions, we determine the variable as a session in the
Session_register ($sessionname), and then we call Session_Start ()
The session variable value is restored at the beginning of the. php page to be used.

As an example:

Session_register (' Val ');
$val = 88;
Session_Start ();
Print $val;

7) Form variables
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 variable alternately, which is unsafe to the method.

8) Server variables
asp: There are many server variables that can be seen in ASP documents. An example:

Request.ServerVariables ("Http_host")

PHP: As an ISAPI mode, server variables are stored in the $http_server_vars array.
As CGI, they are stored in environment variables, with $http_env_vars arrays or getenv ()
Can get. An example:

$HTTP _server_vars["Http_host") using ISAPI module

$HTTP _env_vars["Http_host"] using CGI module

9) Database access
asp: General ADO Technology
Php:ado can be modeled using the ADODB library, which is equivalent to ADO.
The limit is that the read-only cursor and the roll forward cursor are currently supported.

10) Cache Buffer
Asp:Response.Buffer = True
Response.Write ("AAA");
Response.Flush ()
Php:ob_start ();
print "AAA";
Ob_end_flush ();

One) Script Timeout
asp: The time level is the second level:
Server.ScriptTimeout (360)

PHP: Time-level is the second level:
Set_time_limit (360);


If there is a mistake, please advise us.



The above describes the PHP and ASP object equivalence relationship, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.