Php interview questions and my answers (2)

Source: Internet
Author: User
1. in PHP, the name of the current script (excluding the path and query string) is recorded in the predefined variable (1; the URL of the previous page linked to the current page is recorded in the predefined variable (2? Php page address, SCRIPT_NAME can also be: phptest. phpecho $ _ SERVER [PHP_SELF]. br; link to the current page

1. in PHP, the name of the current script (excluding the path and query string) is recorded in the predefined variable (1; the URL of the previous page linked to the current page is recorded in the predefined variable (2? Php // This page address, SCRIPT_NAME can also be: php/test. php echo $ _ SERVER ['php_self ']. br/; // link to the current page

1. in PHP, the name of the current script (excluding the path and query string) is recorded in the predefined variable (1; the URL of the previous page linked to the current page is recorded in the predefined variable (2 ).

// This page address, SCRIPT_NAME can also be: php/test. php
Echo $ _ SERVER ['php _ SELF ']."
";
// URL of the previous page linked to the current page:
Echo $ _ SERVER ['HTTP _ referer']."
";

// For other pre-defined variables, see reference manual: Language Reference variables.
// The absolute path name of the script before execution: D: Inetpubwwwrootphp est. php
Echo $ _ SERVER ["SCRIPT_FILENAME"]."
";
// Browsing the IP address of the user on the current page: 127.0.0.1
Echo $ _ SERVER ["REMOTE_ADDR"]."
";
// Query string (the first question mark in the URL? ): Id = 1 & bi = 2
Echo $ _ SERVER ["QUERY_STRING"]."
";
// The root directory of the file where the script is currently running: d: inetpubwwwroot
Echo $ _ SERVER ["DOCUMENT_ROOT"]."
";
?>

2. Execution Section Output __.

// Reference manual Language Reference operator Arithmetic Operator % is a modulo operation and outputs 0
Echo 8% (-2 )."
";
// The result of Modulo $ a % $ B when $ a is a negative value is also a negative value. Output-2
Echo (-8) % 3 )."
";
// Output 2
Echo (8% (-3 ))."
";
?>

3. In HTTP 1.0, Status Code 401 indicates ____. If the "file not found" prompt is returned, the header function is available, and its statement is ____.

Answer: 401 indicates that authorization is Not performed. header ("HTTP/1.0 404 Not Found"). [See reference manual> function reference> HTTP function header]

4. The role of the Array Function arsort is ____; the role of the error_reporting (2047) Statement is ____.

A: arsort: sorts arrays in reverse order and maintains the index relationship error_reporting (2047). report All errors and warnings

5. Write a regular expression to overwrite all JS/VBS scripts on the web page (that is, remove the script tag and its content ):

$ Script = "the following content is not displayed:

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.