PHP code example of kylewm / brevity

1. Go to this page and download the library: Download kylewm/brevity 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/ */

    

kylewm / brevity example snippets


mb_internal_encoding('UTF-8');

$brevity = new \Kylewm\Brevity\Brevity();
$length = $brevity->tweetLength('Published my first npm www.npmjs.com/package/brevity and composer packagist.org/packages/kylewm/brevity packages today!');
echo $length;  // 99

$brevity = new \Kylewm\Brevity\Brevity();
$html = $brevity->autolink("I'm a big fan of https://en.wikipedia.org/wiki/Firefly_(TV_series) (and its creator https://en.wikipedia.org/wiki/Joss_Whedon)");
echo $html;

$brevity = new \Kylewm\Brevity\Brevity();
$permalink = "https://kylewm.com/2016/01/brevity-shortens-notes";
$longnote = "Brevity (github.com/kylewm/brevity-php) shortens notes that are too long to fit in a single tweet. It can also count characters to help you make sure your note won't need to be shortened!";
$tweet = $brevity->shorten($longnote, $permalink);
echo $tweet;