PHP code example of hidehalo / emoji

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

    

hidehalo / emoji example snippets



use Hidehalo\Emoji\Parser;

$parser = new Parser();
$parser->parse($contents);

# if you want to replace those emoji symbols to ohter marked texts 
# and has ability to turn those back,
# it has a built-in Protocol and Converter could do this
# and $decoded will equals $raw,it is real very simple

use Hidehalo\Emoji\Converter;

$converter = new Converter($parser);
$encoded = $converter->encode($raw);
$decoded = $converter->decode($encoded);

# filter emojis
use Hidehalo\Emoji\Protocol\Filter;

$clean = $converter->encode($raw, new Filter);



use Hidehalo\Emoji\Protocol\ProtocolInterface as Protocol;
use Hidehalo\Emoji\Protocol\PatternAwareTrait;

class CustomProto implments Protocol
{
    use PatternAwareTrait;

    protected $format = "FORMAT";
    protected $pattern = "/FORMAT/";

    public function encode($contents)
    {
        //your impls
    }

    public function decode($contents)
    {
        //your impls
    }
}
$customProto = new CustomProto;
$customEncoded = $converter->encode($raw, $customProto);
$customDecoded = $converter->decode($customDecoded, $customProto);