PHP code example of andrey-helldar / beautiful-phone

1. Go to this page and download the library: Download andrey-helldar/beautiful-phone 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/ */

    

andrey-helldar / beautiful-phone example snippets


// $app->register(App\Providers\AppServiceProvider::class);

use Helldar\BeautifulPhone\Services\Phone;

return (new Phone())->get(/*...params...*/);

return phone('4567');
// returned: <a href='tel:4567'>4567</a>

return phone('fooba');
// returned: <a href='tel:+781236622'><span>+7 (812)</span> 3-66-22</a>

return phone('foobar');
// returned: <a href='tel:+7812366227'><span>+7 (812)</span> 36-62-27</a>

return phone('123123');
// returned: <a href='tel:+7812123123'><span>+7 (812)</span> 123-123</a>

return phone('31234567890');
// returned: <a href='tel:+31234567890'><span>+3 (123)</span> 456-789-0</a>

return phone('+33216549883');
// returned: <a href='tel:+33216549883'><span>+3 (321)</span> 654-98-83</a>

return phone('+33216665557');
// returned: <a href='tel:+33216665557'><span>+3 (321)</span> 666-555-7</a>

return phone('+73216665557');
// returned: <a href='tel:+73216665557'><span>+7 (321)</span> 666-555-7</a>

return phone('+83216665557');
// returned: <a href='tel:+73216665557'><span>+7 (321)</span> 666-555-7</a>

return phone('4567', 1234);
// returned: <a href='tel:4567'>4567</a>

return phone('fooba', 1234);
// returned: <a href='tel:+7123436622'><span>+7 (1234)</span> 3-66-22</a>

return phone('foobar', 1234);
// returned: <a href='tel:+71234366227'><span>+7 (1234)</span> 36-62-27</a>

return phone('123123', 1234);
// returned: <a href='tel:+71234123123'><span>+7 (1234)</span> 123-123</a>

return phone('31234567890', 1234);
// returned: <a href='tel:+31234567890'><span>+3 (1234)</span> 567-890</a>

return phone('+33216549883', 1234);
// returned: <a href='tel:+33216549883'><span>+3 (321)</span> 654-98-83</a>

return phone('+33216665557', 1234);
// returned: <a href='tel:+33216665557'><span>+3 (321)</span> 666-555-7</a>

return phone('+73216665557', 1234);
// returned: <a href='tel:+73216665557'><span>+7 (321)</span> 666-555-7</a>

return phone('+83216665557', 1234);
// returned: <a href='tel:+73216665557'><span>+7 (321)</span> 666-555-7</a>

return phone('4567', 0, false);
// returned: <a href='tel:4567'>4567</a>

return phone('fooba', 0, false);
// returned: <a href='tel:+781236622'>+7 (812) 3-66-22</a>

return phone('foobar', 0, false);
// returned: <a href='tel:+7812366227'>+7 (812) 36-62-27</a>

return phone('123123', 0, false);
// returned: <a href='tel:+7812123123'>+7 (812) 123-123</a>

return phone('31234567890', 0, false);
// returned: <a href='tel:+31234567890'>+3 (123) 456-789-0</a>

return phone('+33216549883', 0, false);
// returned: <a href='tel:+33216549883'>+3 (321) 654-98-83</a>

return phone('+33216665557', 0, false);
// returned: <a href='tel:+33216665557'>+3 (321) 666-555-7</a>

return phone('+73216665557', 0, false);
// returned: <a href='tel:+73216665557'>+7 (321) 666-555-7</a>

return phone('+83216665557', 0, false);
// returned: <a href='tel:+73216665557'>+7 (321) 666-555-7</a>

return phone('4567', 0, true, false);
// returned: 4567

return phone('fooba', 0, true, false);
// returned: <span>+7 (812)</span> 3-66-22

return phone('foobar', 0, true, false);
// returned: <span>+7 (812)</span> 36-62-27

return phone('123123', 0, true, false);
// returned: <span>+7 (812)</span> 123-123

return phone('31234567890', 0, true, false);
// returned: <span>+3 (123)</span> 456-789-0

return phone('+33216549883', 0, true, false);
// returned: <span>+3 (321)</span> 654-98-83

return phone('+33216665557', 0, true, false);
// returned: <span>+3 (321)</span> 666-555-7

return phone('+73216665557', 0, true, false);
// returned: <span>+7 (321)</span> 666-555-7

return phone('+83216665557', 0, true, false);
// returned: <span>+7 (321)</span> 666-555-7

return phone('4567', 0, false, false);
// returned: 4567

return phone('fooba', 0, false, false);
// returned: +7 (812) 3-66-22

return phone('foobar', 0, false, false);
// returned: +7 (812) 36-62-27

return phone('123123', 0, false, false);
// returned: +7 (812) 123-123

return phone('31234567890', 0, false, false);
// returned: +3 (123) 456-789-0

return phone('+33216549883', 0, false, false);
// returned: +3 (321) 654-98-83

return phone('+33216665557', 0, false, false);
// returned: +3 (321) 666-555-7

return phone('+73216665557', 0, false, false);
// returned: +7 (321) 666-555-7

return phone('+83216665557', 0, false, false);
// returned: +7 (321) 666-555-7

return phone('4567', 0, false, false, [], true);
// returned: 4567

return phone('fooba', 0, false, false, [], true);
// returned: +781236622

return phone('foobar', 0, false, false, [], true);
// returned: +7812366227

return phone('123123', 0, false, false, [], true);
// returned: +7812123123

return phone('31234567890', 0, false, false, [], true);
// returned: +31234567890

return phone('+33216549883', 0, false, false, [], true);
// returned: +33216549883

return phone('+33216665557', 0, false, false, [], true);
// returned: +33216665557

return phone('+73216665557', 0, false, false, [], true);
// returned: +73216665557

return phone('+83216665557', 0, false, false, [], true);
// returned: +73216665557

$attributes = ["id" => "foo", "class" => "bar baz", "data-value" => "foo"];

// Default parameters:
return phone('foobar', 0, true, true, $attributes);
// returned: <a href="tel:+7812366227" id="foo" class="bar baz" data-value="foo"><span>+7 (812)</span> 36-62-27</a>

// With manual applying city code:
return phone('foobar', 1234, true, true, $attributes);
// returned: <a href="tel:+71234366227" id="foo" class="bar baz" data-value="foo"><span>+7 (1234)</span> 36-62-27</a>

// With disabled html formatting into phone number:
return phone('foobar', 0, false, true, $attributes);
// returned: <a href="tel:+7812366227" id="foo" class="bar baz" data-value="foo">+7 (812) 36-62-27</a>

// With enabled html formatting and disabled `is_link` parameter into phone number:
return phone('foobar', 0, true, false, $attributes);
// returned: <span>+7 (812)</span> 36-62-27

// With disabled html formatting and `is_link` parameter into phone number:
return phone('foobar', 0, false, false, $attributes);
// returned: +7 (812) 36-62-27

use Helldar\BeautifulPhone\Facades\Phone;

return Phone::spanLink('foobar');
// returned: <a href='tel:+7812366227'><span>+7 (812)</span> 36-62-27</a>

return Phone::cleanLink('foobar');
// returned: <a href='tel:+7812366227'>+7 (812) 36-62-27</a>

return Phone::span('foobar');
// returned: <span>+7 (812)</span> 36-62-27

return Phone::clear('foobar');
// returned: +7 (812) 36-62-27

return Phone::fullClear('foobar');
// returned: +7812366227
shell script
php artisan vendor:publish --provider="Helldar\BeautifulPhone\ServiceProvider"