The main points are as follows: 1. there is no documentation for the framework; 2. there is no comment in the source code of the framework; 3. few people in our department are familiar with the use of this framework except for the main line developers; if you want to use this framework to do things, there is only one way: look at the source code, first understand the implementation principle of the framework, and then use this bird to do things. When I see a request processing class, the following code comes into view: staticfunctionget_base_url () {mainly has the following points:
1. this framework has no documentation;
2. there is no comment in the framework source code;
3. in addition to the main line developers, few of our departments are familiar with this feature;
If you want to use this framework to do things, there is only one way: look at the source code, first understand the implementation principle of the framework, and then use this bird to do things.
When I saw a request processing class, the following code came into view:
static function get_base_url(){ $filename = (isset($_SERVER['SCRIPT_FILENAME'])) ? basename($_SERVER['SCRIPT_FILENAME']) : ''; if (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $filename) { $base_url = $_SERVER['ORIG_SCRIPT_NAME']; } elseif (isset($_SERVER['SCRIPT_NAME']) && basename($_SERVER['SCRIPT_NAME']) === $filename) { $base_url = $_SERVER['SCRIPT_NAME']; } elseif (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) === $filename) { $base_url = $_SERVER['PHP_SELF']; } else { $path = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : ''; $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; } while (($last > $index) && (false !== ($pos = strpos($path, $base_url))) && (0 != $pos)); } $request_uri = self::get_request_uri(); if (0 === strpos($request_uri, $base_url)) { return 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); } $basename = basename($base_url); if (empty($basename) || !strpos($truncatedrequest_uri, $basename)) { return; } if ((strlen($request_uri) >= strlen($base_url)) && ((false !== ($pos = strpos($request_uri, $base_url))) && ($pos !== 0))) { $base_url = substr($request_uri, 0, $pos + strlen($base_url)); } return rtrim(self::dirname($base_url), '/'); }
12 Next page