示例#1
0
<?php

use Carrot\DependencyInjection\Reference, Carrot\DependencyInjection\Injector\ConstructorInjector, Carrot\DependencyInjection\Injector\ProviderInjector, Carrot\DependencyInjection\Injector\CallbackInjector;
use Carrot\Routing\HTTPURI;
# Set up autoloader
$autoloader = (require 'autoloader.php');
$autoloader->register();
$uri = new HTTPURI('http', $_SERVER['SERVER_NAME'], $_SERVER['REQUEST_URI'], $_GET);
echo '<pre>$_GET = ', var_dump($_GET), '</pre>';
echo '<pre>', var_dump($uri->getScheme()), '</pre>';
echo '<pre>', var_dump($uri->getScheme()), '</pre>';
echo '<pre>', var_dump($uri->pathMatches('/^\\/bläh/u')), '</pre>';
?>
<a href="<?php 
echo $uri->get();
?>
"><?php 
echo $uri->get();
?>
</a>
<?php 
exit;
# Test URI
$string = 'http://www.ics.uci.edu/pub/ietf/uri/?br%C3%BCk=blük#Related';
//$string = 'xmpp:user@host/resource';
preg_match_all('/^(([^:\\/?#]+):)?(\\/\\/([^\\/?#]*))?([^?#]*)(\\\\?([^#]*))?(#(.*))?/', $string, $matches);
echo '<pre>', var_dump($matches), '</pre>';
echo '<pre>', var_dump(substr($matches[7][0], 1)), '</pre>';
parse_str(substr($matches[7][0], 1), $get);
echo '<pre>PARSE_STR = ', var_dump($get), '</pre>';
?>
示例#2
0
 /**
  * Test pattern matching methods using unicode.
  *
  */
 public function testPathPatternMatchingUnicode()
 {
     $uri = new HTTPURI('https', 'example.org', '/sûr!/㈱a̢̱̠̼̐͊͋͗ͤ͑͘͝͡カ゚ㄤ/glück');
     $this->assertEquals(FALSE, $uri->pathMatches('/^mädchen/u'));
     $this->assertEquals(TRUE, $uri->pathMatches('/^\\/sûr/u'));
     $this->assertEquals(FALSE, $uri->pathMatches('/^\\/!/u', 'sûr'));
     $this->assertEquals(TRUE, $uri->pathMatches('/^\\/㈱a̢̱̠̼̐͊͋͗ͤ͑͘͝͡カ゚ㄤ\\/glück$/u', 'sûr!'));
 }