Code: Select all
<?php
function curPageURL()
{
$pageURL = (isset($_SERVER['HTTPS']) && ($_SERVER["HTTPS"] == "on")) ? 'https://' : 'http://';
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$url = curPageURL();
$original = "fred";
$replace = "Sally";
$domainreplace = preg_replace ('$original', '$replace', '$url');
echo "$url<br/>$original<br/>$replace<br/>Go to: $domainreplace";
?>I think it's going wrong because $url will have :// and other // in it. Maybe even & signs.
How do I escape all those, and make this work?
Right now it is not echoing "$domainreplace".