dev-master
9999999-devClass to create clean Urls for blogs, forums and other websites
MIT
The Requires
- php >=5.0.0
url link seo encode translit slug transliteration transliterate prettyurl
Wallogit.com
2017 © Pedro Peláez
Class to create clean Urls for blogs, forums and other websites
Class to create clean Urls for blogs, forums and other websites, (*1)
$ composer require prettyurl/prettyurl:dev-master
setUrl, getUrl, setType, getType, setMaxLength, getMaxLength, setBlackList, getBlackList, loadDict, addChars, validate, Urlify, (*2)
To generate URLs for titles or sections, (*3)
require 'lib/PrettyUrl.php'; use PrettyUrl; $url = new PrettyUrl('TweetBeeg to write tweets with more than 140 characters'); $newUrl = $url->Urlify(); echo $newUrl; // or echo $url->getUrl(), is the same // result: 'tweetbeeg-to-write-tweets-with-more-than-140-characters'
Generate URLs and eliminate words from the black list, (*4)
require 'lib/PrettyUrl.php'; use PrettyUrl; $url = new PrettyUrl('TweetBeeg to write tweets with more than 140 characters'); // black list is case insensitive so 'WItH' is the same that 'with' $url->setBlackList(array( 'with', 'to' )); $url->Urlify(); // now with the encoded url and without with and than words echo $url->getUrl(); // result: 'tweetbeeg-write-tweets-more-than-140-characters'
Automatically delete invalid characters from URLs, (*5)
require 'lib/PrettyUrl.php'; use PrettyUrl; $text = ' bes\t tíñtle$ $ that.\'_ _can# be mundo/ / ( \3000€ /set%&$@ '; $url = new PrettyUrl($text); $url->Urlify(); echo $url->getUrl(); // result: 'best-tintle-that-can-be-mundo-3000-set'
Generating URLs for files, (*6)
require 'lib/PrettyUrl.php'; use PrettyUrl; /* if the second parameter is true adapt the URL * to files keeping the extension * by default the value is false */ $url = new PrettyUrl('TweetBeeg tall tweets.jpg', true); $newUrl = $url->Urlify(); echo $newUrl; // result: 'tweetbeeg-tall-tweets.jpg'
Generating URLs with a determinate length. If the length is higher that the defined the Url will be shorted., (*7)
require 'lib/PrettyUrl.php'; use PrettyUrl; $url = new PrettyUrl('TweetBeeg tall tweets $$Jlkjs~write more than ?¿ 140 character$=@'); /* * also valid * $url = new PrettyUrl('TweetBeeg tall tweets $$Jlkjs~write more than ?¿ 140 character$=@', false, 20); */ $url->setMaxLength(20); $newUrl = $url->Urlify(); echo $newUrl; // result: 'tweetbeeg-tall-tweet'
Class to create clean Urls for blogs, forums and other websites
MIT
url link seo encode translit slug transliteration transliterate prettyurl