Views (468) Comment (0) 17-11-2018

Friendly URL helps users to move around web applications easily.  Friendly URL improves SEO, also project database from SQL injection and autoincrement values. Most at times you notice urls link: https://example.com/friendly-url-in-php. Below is the programming function on how to create Friendly URL in PHP.

	 function String_Url($text) {
# allow only alphanumeric
		 $stringU = preg_replace("/[^a-zA-Z0-9]+/", " ", $text);
		$replace_space = str_replace(' ', '-', $stringU); // Converts spaces to dashes
		$encode_string  = urlencode(strtolower($replace_space));
		return $encode_string;
	}