Contents |
eV::fullyQualifyAllURLs($domain,$copy) returns a string where all non-fully qualified URLs are prepended with the value $domain. This is useful for pages that will be presented outside of the domain of the website (emailed, used for API data, etc).
$string = eV::fullyQualifyAllURLs($domain,$copy);
Returns a string identical to the incoming $copy string, except for URLs that where non-fully qualified are no fully qualified with the passed $domain.
// set data to be fixed. $dataString = " This is some text with an <a href=\"page.html\">absolute link</a>, a <a href=\"http://www.google.com\">fully qualified domain name link</a> and a <form action=\"anotherpage.html\" method=\"post\">form</form> "; // convert all non-fully qualified URLs to fully qualified $newDataString = eV::fullyQualifyAllURLs('http://www.website.com',$dataString); // output the resulting string echo $newDataString; /* this string will look like the following: -------------------------- This is some text with an <a href=\"http://www.website.com/page.html\">absolute link</a>, a <a href=\"http://www.google.com\">fully qualified domain name link</a> and a <form action=\"http://www.website.com/anotherpage.html\" method=\"post\">form</form> */