Пример #1
0
 public function testSetOrderedParameterArrayFail()
 {
     $urlCfg = new ezcUrlConfiguration();
     $urlCfg->addOrderedParameter('param2');
     $url = new ezcUrl('http://www.example.com', $urlCfg);
     try {
         $url->setParam('param2', array('x'));
         $this->fail('Expected exception was not thrown.');
     } catch (ezcBaseValueException $e) {
         $this->assertEquals("The value 'a:1:{i:0;s:1:\"x\";}' that you were trying to assign to setting 'param2' is invalid. Allowed values are: string.", $e->getMessage());
     }
 }
Пример #2
0
<?php

require_once 'tutorial_autoload.php';
// create an ezcUrlConfiguration object
$urlCfg = new ezcUrlConfiguration();
// set the basedir and script values
$urlCfg->basedir = 'mydir';
$urlCfg->script = 'index.php';
// define delimiters for unordered parameter names
$urlCfg->unorderedDelimiters = array('(', ')');
// define ordered parameters
$urlCfg->addOrderedParameter('section');
$urlCfg->addOrderedParameter('group');
$urlCfg->addOrderedParameter('category');
$urlCfg->addOrderedParameter('subcategory');
// define unordered parameters
$urlCfg->addUnorderedParameter('game', ezcUrlConfiguration::MULTIPLE_ARGUMENTS);
$urlCfg->addUnorderedParameter('patches', ezcUrlConfiguration::AGGREGATE_ARGUMENTS);
// create a new ezcUrl object from a string url and use the above $urlCfg
$url = new ezcUrl('http://www.example.com/mydir/index.php/groups/Games/Adventure/Adult/(game)/Larry/7', $urlCfg);
var_dump($url->buildUrl());
// set the parameter values in the url
$url->setParam('subcategory', 'Kids');
$url->setParam('game', array('Monkey_Island', '3'));
var_dump($url->buildUrl());
$url->setParam('patches', array(array('beta1'), array('rc1', 'rc2')));
var_dump($url->buildUrl());