Having the item title in the URL is a good way to improve SEO for your website. For example, /shop/adobe_photoshop_cs5/ is much more meaningful to users and search engines than /shop.php?i=83s9f8haj8dj. Unfortunately, not all characters are valid in URLs, which is where a permalink function comes handy to convert titles into a nice URL format. Permalinks usually remove all non-alphanumerical characters and replace spaces with underscores. “Adobe Photoshop CS5” is then converted to “adobe_photoshop_cs5”.

function permalize($input) {
	return str_replace(' ','_',strtolower(trim(preg_replace("/[^a-zA-Z0-9 ]/", '', $input))));
}

Note that you can use some special characters in URLs (like + and -), I usually like to remove them completely, but it is totally fine to leave them should you choose to.

If you don’t want to rely on a permalink to retrieve database data about your item, you can still insert the ID in the URL (e.g. /shop/34655/adobe_photoshop_cs5/ ). The permalink could then be discarded in the code while still providing better readability and SEO.