PHP code example of nerweb / laravel-shortcode

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

    

nerweb / laravel-shortcode example snippets


'Nerweb\Shortcode\ShortcodeServiceProvider',

'Shortcode' => 'Nerweb\Shortcode\Facades\Shortcode',

$string = '
Hi [FIRST_NAME] [LAST_NAME],

To confirm your account.

please click [confirm_url title="Confirm example" text="here"]

or

[CONFIRM_URL_TEXT]

Thanks,
[FROM_NAME]
';

Shortcode::register('FROM_NAME', 'Lisa Dy');

Shortcode::register('confirm_url', function($parameters = array(), $Shortcode) {
    // short code available parameters
    $href           = array_get($parameters, 'href');
    $title          = array_get($parameters, 'title');
    $text           = array_get($parameters, 'text');

    // link
    return link_to($Shortcode->get('CONFIRM_URL_TXT'), $text, array(
        'title' => $title
    ));
});

// Register on decode
echo Shortcode::decode($string, array(
    'FIRST_NAME'        => 'Hamill',
    'LAST_NAME'         => 'Esmeralda',
    'CONFIRM_URL_TEXT'  => URL::to('/account/confirm/?something=here')
));