PHP $_server[' orig_script_name ']

Source: Internet
Author: User
Because it's a new feature of a project, this new feature is made with the company's newly developed framework.

This frame is very NB Ah, NB to where that. There are several main points:

1, the framework has no documentation;

2, the framework of the source code is not annotated;

3, in addition to the main line of developers of our department few people familiar with the use;

If you want to use this framework to do things, there is only one way: Look at the source code, first understand the framework of the implementation of the principle, and then use this bird thing to do things.

When I see a class that handles the request, the following code looks like this:

              

1 static function Get_base_url () {2 $filename = (isset ($_server [' script_filename '])) ? basename ($_server [' Script_filename ']): '; 3 if (isset ($_server [' orig_script_name ')) && basename ($_server [' orig_script_name ']) = = = $filename) {4 $base _url = $_server [' Orig_script_name ']; 5} elseif (Isset ($_server [' script_name ']) && basename ($_server [' script_name ']) = = = $filename) {6 $base _url = $_server [' Script_name ']; 7} elseif (Isset ($_server [' php_self ']) && BASEname ($_server [' php_self ']) = = = $filename) {8 $base _url = $_server [' php_self ']; 9} else {$path = Isset ($_server [' php_self ']) ? $_server [' php_self ']: '; One $file = Isset ($_server [' script_filename '])? $_server [' Script_filename ']: '; $segs = explode ('/', trim ($file, '/') )); $segs = Array_reverse ($segs); $index = 0; $last = count ($segs); $base _url = "; + do {$seg = $segs [ $index]; $base _url = '/'. $seg. $base _url; + + + $index; ($last > $index) && (False!== ($p OS = Strpos ($path, $base _url))) && (0! = $pos )); $request _uri = self:: Get_request_uri (); if (0 = = Strpos ($request _uri, $base _url)) {$ re Turn self:: dirname ($base _url); if (0 = = Strpos ($request _uri, dirname ($base _ URL)) {return self:: dirname ($base _url); $truncatedrequest _uri = $request _uri; if ($pos = Strpos ($request _uri, '? !== false) {$truncatedrequest _uri = substr ($request _uri , 0, $pos); The PNs $basename = basename ($base _url); if (Empty ($basename) | | ! Strpos ($truncatedrequest _uri, $basename)) {; (Strlen ($request _uri) >= strlen ($base _ URL) && (false!== ($pos = Strpos ($request _ur I, $base _url))) && ($pos!== 0)) {$base _url = substr ($request _uri, 0, $pos + StrlEn ($base _url)); RTrim Return (self:: dirname ($base _url), '/' ); 47}

There are so many things to learn, and for the first time today I see $_server[' orig_script_name ' this variable. What do you do? It's not clear.

Previously I just knew $_server[' script_name '] this variable.

I have always been the inquisitive, what is not clear, if not to get out, uncomfortable ah.

Use degree Niang search under, see this passage:

To know whether PHP is currently running through CGI or inside Apache, you can check the environment variable orig_script_name.
If PHP runs through CGI, the value of this variable is/php/php.exe.
If Apache runs the php script as a module, the value of the variable should be/phptest.php

It just dawned on me. It turns out that's the reason.

It seems that I want to learn PHP well, learn the essence of a lot of Kung fu ah.

This is the only record.

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