PHP code example of fallenangelbg / quickshorturl

1. Go to this page and download the library: Download fallenangelbg/quickshorturl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fallenangelbg / quickshorturl example snippets



use Fallenangelbg\QuickShortURL;

$uniqueId = 57819;
$convertedToLetters = shortUrl::buildShortLink($uniqueId);
echo $convertedToLetters;
// Result is 'QZpfw'

$lettersToBeConverted = 'mwwjj';
$convertedToUniqueId = shortUrl::buildShortLink($uniqueId);
echo $convertedToUniqueId;
// Result is 49933

use Fallenangelbg\QuickShortURL;
$myId = $db->query("SELECT `id` FROM `blog` WHERE `slug` = 'some-article-to-be-displayed' ");
$shortUrl = $_SERVER['SERVER_NAME'] . "/l/" . shortUrl::buildShortLink($myId);
echo $shortUrl;
// result: www.example.com/l/QZwwj

use Fallenangelbg\QuickShortURL;
/** get the part after '/l/' */
$shortUrlFromAddress = $parsedString;
$foundId = shortUrl::buildShortLink($shortUrlFromAddress);
$mySlug = $db->query("SELECT `slug` FROM `blog` WHERE `id` = '$foundId' ");

header("Location: https://www.example.com/blog/entry/" . $mySlug . ".html");
exit;