Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; cronometro has a deprecated constructor in /home/wdrfree/public_html/model/admin/model.php on line 4
How To Program SEO Friendly URLs using PHP | wdrfree ▷

How To Program SEO Friendly URLs using PHP

Saturday 07th, Nov, 2015 | #PHP #SEO


A friendly URL is a Web address that is easy to read and includes words that describe the content of the webpage. This type of URL can be "friendly" in two ways. 1) It can help visitors remember the Web address, and 2) it can help describe the page to search engines.

You can use the next php script to convert any string to  friendly URL


<?
function fUrl($string)
{
 $url = str_replace("'", '', $string);
 $url = str_replace('%20', ' ', $url);
 $url = preg_replace('~[^\\pL0-9_]+~u', '-', $url);
 $url = trim($url, "-");
 $url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
 $url = strtolower($url);
 $url = preg_replace('~[^-a-z0-9_]+~', '', $url);
 return $url;
}
//USE
echo "Hola Mundo";
//hola-mundo 
?>