本文整理汇总了PHP中Net_URL2::setPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2::setPath方法的具体用法?PHP Net_URL2::setPath怎么用?PHP Net_URL2::setPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_URL2
的用法示例。
在下文中一共展示了Net_URL2::setPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUrl
/**
* Sets the URL for this request
*
* If the URL has userinfo part (username & password) these will be removed
* and converted to auth data. If the URL does not have a path component,
* that will be set to '/'.
*
* @param string|Net_URL2 $url Request URL
*
* @return HTTP_Request2
* @throws HTTP_Request2_LogicException
*/
public function setUrl($url)
{
if (is_string($url)) {
$url = new Net_URL2($url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']));
}
if (!$url instanceof Net_URL2) {
throw new HTTP_Request2_LogicException('Parameter is not a valid HTTP URL', HTTP_Request2_Exception::INVALID_ARGUMENT);
}
// URL contains username / password?
if ($url->getUserinfo()) {
$username = $url->getUser();
$password = $url->getPassword();
$this->setAuth(rawurldecode($username), $password ? rawurldecode($password) : '');
$url->setUserinfo('');
}
if ('' == $url->getPath()) {
$url->setPath('/');
}
$this->url = $url;
return $this;
}
示例2: appendUrlPath
/**
* Appends url path.
*
* @param string $urlPath url path to append.
*
* @return none.
*/
public function appendUrlPath($urlPath)
{
Validate::isString($urlPath, 'urlPath');
$newUrlPath = parse_url($this->_url, PHP_URL_PATH) . $urlPath;
$this->_url->setPath($newUrlPath);
}
示例3: setUrl
/**
* Sets the URL for this request
*
* If the URL has userinfo part (username & password) these will be removed
* and converted to auth data. If the URL does not have a path component,
* that will be set to '/'.
*
* @param string|Net_URL2 Request URL
* @return HTTP_Request2
* @throws HTTP_Request2_Exception
*/
public function setUrl($url)
{
if (is_string($url)) {
$url = new Net_URL2($url);
}
if (!$url instanceof Net_URL2) {
throw new HTTP_Request2_Exception('Parameter is not a valid HTTP URL');
}
// URL contains username / password?
if ($url->getUserinfo()) {
$username = $url->getUser();
$password = $url->getPassword();
$this->setAuth(rawurldecode($username), $password ? rawurldecode($password) : '');
$url->setUserinfo('');
}
if ('' == $url->getPath()) {
$url->setPath('/');
}
$this->url = $url;
return $this;
}
示例4: array
$project_link->setLabel("Project Homepage");
$project_link->addFilter("htmlspecialchars");
$project_link->addRule('required', "Please enter your project link");
$is_active = $form->addElement("checkbox", 'is_active', array('checked' => $channel["is_active"] ? 'checked' : ''));
$is_active->setLabel("Active?");
$form->addElement("submit");
if ($form->validate()) {
$url = new Net_URL2($project_name->getValue());
try {
$req = new HTTP_Request2();
$dir = explode("/", $url->getPath());
if (!empty($dir)) {
array_pop($dir);
}
$dir[] = 'channel.xml';
$url->setPath(implode("/", $dir));
$req->setURL($url->getURL());
channel::validate($req, $chan);
channel::edit($channel['name'], $project_label->getValue(), $project_link->getValue(), $contact_name->getValue(), $contact_email->getValue());
if ($is_active->getValue()) {
channel::activate($channel['name']);
} else {
channel::deactivate($channel['name']);
}
echo "<div class=\"success\">Changes saved</div>\n";
} catch (Exception $exception) {
echo '<div class="errors">';
switch ($exception->getMessage()) {
case "Invalid channel site":
case "Empty channel.xml":
echo "The submitted URL does not ";
示例5: test20157
/**
* This is a regression test to test that setting "0" as path
* does not break normalize().
*
* It was reported as Bug #20157 on 2013-12-27 23:42 UTC that
* normalize() with "0" as path would not work.
*
* @covers Net_URL2::normalize
* @return void
*/
public function test20157()
{
$subject = 'http://example.com';
$url = new Net_URL2($subject);
$url->setPath('0');
$url->normalize();
$this->assertSame("{$subject}/0", (string) $url);
}