Home > Backend Development > PHP Tutorial > PHP gets the current script URL and relative path and converts it into an absolute path regular_PHP tutorial

PHP gets the current script URL and relative path and converts it into an absolute path regular_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 16:59:10
Original
1093 people have browsed it

php tutorial to obtain the current script URL and relative path and convert it into an absolute path regular

function relative_to_absolute($content, $feed_url) {
preg_match('/(http|https tutorial|ftp):///', $feed_url, $protocol);
$server_url = preg_replace("/(http|https|ftp|news):///", "", $feed_url);

$server_url = preg_replace("//.*/", "", $server_url);
If ($server_url == '') {
           return $content;                                   }  
If (isset($protocol[0])) {
$new_content = preg_replace('/href="//', 'href="'.$protocol[0].$server_url.'/', $content);
$new_content = preg_replace('/src="//', 'src="'.$protocol[0].$server_url.'/', $new_content);
} else {
$new_content = $content;
}  
Return $new_content;
}
?>

//Get the current script URL

function get_php_url(){
If(!empty($_server["request_uri"])){

$scriptname = $_server["request_uri"];

$nowurl = $scriptname;
         }else{
$scriptname = $_server["php_self"]; //
If(empty($_server["query_string"])) $nowurl = $scriptname;
                       else $nowurl = $scriptname."?".$_server["query_string"];
}

//

return $nowurl;

}

?>

http://www.bkjia.com/PHPjc/631345.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631345.htmlTechArticlephp tutorial to get the current script URL and relative path and convert it into an absolute path regular? function relative_to_absolute($content, $feed_url ) { preg_match('/(http|https tutorial|ftp):///', $fe...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template