Php obtains the current script URL and relative path and converts it to an absolute path regular. In the php Tutorial, how does one convert the current script URL and relative path to the absolute path regular? Functionrelative_to_absolute ($ content, $ feed_url) {preg_match (http | https tutorial | ftp):, $ fe php Tutorial. get the current script URL and relative path and convert it to 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;
}
?>
// Obtain 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;
}
?>
Why is the current script URL and relative path converted to an absolute path regular? Function relative_to_absolute ($ content, $ feed_url) {preg_match ('/(http | https tutorial | ftp): //', $ fe...