php tutorial to obtain the current script URL and relative path and convert it into an absolute path regular
//Get the current script URL
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;
}
?>
?>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;
}