PHP code to generate safe URL?
问题 We need to generate a unique URL from the title of a book - where the title can contain any character. How can we search-replace all the 'invalid' characters so that a valid and neat lookoing URL is generated? For instance: "The Great Book of PHP" www.mysite.com/book/12345/the-great-book-of-php "The Greatest !@#$ Book of PHP" www.mysite.com/book/12345/the-greatest-book-of-php "Funny title " www.mysite.com/book/12345/funny-title 回答1: Ah, slugification // This function expects the input to be