コード例 #1
0
ファイル: UrlifyTest.php プロジェクト: oodle/urlify
 public function testUrlify()
 {
     $urltests = array("This Test's Apostrophe" => 'this-tests-apostrophe', "@#\$%@##^@ @#%@#\$%@#\$%@#\$%@#\$%" => '-', "" => '-', "_+0990-0&*(&*(*)(&&*)(&*)(32@#%" => '-0990-0-and-32-', 10000 => '10000', 'kra�t' => 'kraut', "ע" => 'o', "ף" => 'o', "פ" => 'o', "ץ" => 'o', "צ" => 'o', "ר" => 'o', "ש" => 'u', "ת" => 'u', "�" => 'u', "�" => 'u', "‎" => 'y', "������������������������������‗אבגדהוזחטיךכלםמןנסעףפץצרשת��‎‏�" => strtolower("AAAAAAAECEEEEIIIIETHNOOOOOOUUUUYTHORNszaaaaaaaeceeeeiiiiethnoooooouuuuythorny"));
     foreach ($urltests as $key => $value) {
         print "Testing {$key} urlifies to: {$value}\n";
         $this->assertEquals($value, Urlify::urlify($key, '-', 'and'));
         print "Testing {$key} urlifies with '+' to: " . str_replace('-', '+', $value) . "\n";
         $this->assertEquals(str_replace('-', '+', $value), Urlify::urlify($key, '+', 'and'));
     }
     print "\n";
 }
コード例 #2
0
ファイル: test.php プロジェクト: oodle/urlify
<?php

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/src/Urlify/Urlify.php';
use Urlify\Urlify;
echo Urlify::urlify('blah blah blah');
echo "\n";
// Should output "blah-blah-blah"
echo Urlify::urlify('This is a sentence.');
echo "\n";
// Should output "This-is-a-sentence"
echo Urlify::urlify(utf8_decode("kraüt"));
echo "\n";
// Should output "kraut"
echo Urlify::urlify('what ever', '.');
echo "\n";
// Should output "what.ever"
echo Urlify::urlify('blah&blah');
echo "\n";
// Should output "blah-blah"
echo Urlify::urlify('blah&blah', '-', 'and');
echo "\n";
// Should output "blah-and-blah"