PHP code example of maxdancepro / yii2-phone-formatter

1. Go to this page and download the library: Download maxdancepro/yii2-phone-formatter 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/ */

    

maxdancepro / yii2-phone-formatter example snippets


'components' => [
    'formatter' => [
        'class' => 'maxdancepro\phoneFormatter\i18n\Formatter',
    ],
],

echo \Yii::$app->formatter->asPhone('9195230345');

echo \Yii::$app->formatter->asPhone('9195230345','RU', false);

/**
     * 
     * Эта функция может принимать 11-значный, 10-значный, 7-значный или 6-значный номер
     * телефона и
     * возвращает
     *
     * @param int $number Номер телефона, который будет отформатирован
     *
     * @param string $code Код страны, по умолчанию Россия (RU -> +7)
     * @param bool $link Выводить телефон в виде HTML ссылки
     * @param array $options Опции для HTML ссылки
     *
     * @return string
     */
    public function asPhone($number, $code = 'RU', $link = true, array $options = [])
    {
        if ($number == null) {
            return $this->nullDisplay;
        } else {
            return $this->formatPhone($number, $code, $link, $options);
        }
    }

php composer.phar