slug() публичный статический Метод

Method to convert the string into an SEO-friendly slug.
public static slug ( string $string, string $sep = null ) : string
$string string
$sep string
Результат string
Пример #1
0
 public function testSlug()
 {
     $this->assertEquals('hello-world', String::slug($this->string));
     $this->assertEquals("hello/world", String::slug('Hello | World', ' | '));
     $this->assertEquals('', String::slug(''));
 }
Пример #2
0
<?php

require_once '../../bootstrap.php';
use Pop\Filter\String;
try {
    $html = 'Some text, http://www.google.com/ and also https://www.google.com/ and someone@email.com and ftp://ftp.someserver.com';
    echo 'Links: ' . String::links($html, true) . '<br /><br />' . PHP_EOL;
    echo 'Slug: ' . String::slug('Testing, 1, 2, 3 | About Us | Hello World!', ' | ') . '<br /><br />' . PHP_EOL;
    echo 'Random String: ' . String::random(6, String::ALPHANUM, String::UPPER) . '<br /><br />' . PHP_EOL;
} catch (\Exception $e) {
    echo $e->getMessage();
}