本文整理汇总了PHP中URL::create方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::create方法的具体用法?PHP URL::create怎么用?PHP URL::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_todos
function display_todos($items)
{
foreach ($items as $todo) {
?>
<div>
<?php
echo Form::checkbox('done', $todo->done, 'onclick="document.location.href=\'' . URL::create('todo', 'checkbox', array('id' => $todo->id)) . '\'"');
?>
<?php
echo $todo->description;
?>
<?php
echo $todo->project->name;
?>
<a href="<?php
echo URL::create('todo', 'edit', array('id' => $todo->id));
?>
">Edit</a>
<a
href="<?php
echo URL::create('todo', 'delete', array('id' => $todo->id));
?>
"
onclick="return confirm('Are you sure you want to delete this entry: <?php
echo $todo->description;
?>
');"
>
Distroy
</a>
</div>
<br />
<?php
}
}
示例2: redirect
public static function redirect($controller, $action = null, array $args = array(), array $params = array(), $hard = false)
{
if (stristr($controller, 'http://') || stristr($controller, 'https://')) {
//if page is a URL, then set $url as page
$url = $controller;
} else {
//if page is NOT a URL, then set generate a $url from page
$url = URL::create($controller, $action, $args, $params);
}
Util::redirect($url, $hard);
exit;
}
示例3: filter
public function filter($action, array $args = array())
{
$this->action = $action;
$this->args = $args ? $args : array();
$this->extension = "json";
$this->url = URL::create($this->slug, null, $this->args);
$this->fullURL = URL::create($this->slug, null, $this->args, $this->get->toArray());
// Remove empty values from the args array
foreach ($this->args as $key => $arg) {
if (empty($arg) || $arg == '') {
unset($this->args[$key]);
}
}
if (!in_array(strtolower($this->action), array('post', 'get', 'put', 'delete'))) {
throw new RESTException("Invalid API verb: {$this->action}. Choose either 'POST', 'GET', 'PUT', 'DELETE'");
}
// Return a 404 for methods that don't exist
if (!method_exists($this, $this->action)) {
$this->status = 404;
$this->message = "Method '{$this->action}' not supported on this resource";
}
// Hack PHP into supporting DELETE and PUT verbs
// (Merge in the POST array because clients that don't support
// all of the RESTful verbs are going to POST to use PUT)
if ($this->useDataStream && in_array(strtolower($this->action), array('delete', 'put'))) {
$data = array();
parse_str(file_get_contents('php://input'), $data);
$this->{$action}->update(array_merge($this->post->toArray(), $data));
}
if ($this->beforeFilter() === false) {
return;
}
call_user_method_array($this->action, $this, $this->args);
if ($this->afterFilter() === false) {
return;
}
$this->render();
}
示例4:
<form action="<?= URL::create('Match', 'process'); ?>" method="post" enctype="multipart/form-data">
<label for="repository">GitHub Repository URL:</label>
<input type="text" name="repository" id="repository" />
<p id="or">- or -</p>
<label for="file">Upload File:</label>
<input type="file" name="file" id="file" />
<input type="submit" name="search" value="Match" />
</form>
示例5: get
public function get($uri, $params = null)
{
$url = \URL::create($uri, $params, $this->options['baseUrl']);
return new RequestWrapper($this->getClient()->get($url, $this->getDefaultHeaders())->send());
}
示例6: foreach
<div class="container-fluid">
<div class="row">
<?php
if (f('auth.authorize', '/menu')) {
?>
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<?php
if (!empty($app->theme->options['menu'])) {
?>
<?php
foreach ($app->theme->options['menu'] as $menu) {
?>
<li><a href="<?php
echo URL::create($menu['url']);
?>
"><?php
echo $menu['label'];
?>
</a></li>
<?php
}
?>
<?php
}
?>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<?php
示例7:
<ul>
<li><a href="<?= URL::create(); ?>">Home</a></li>
<li><a href="<?= URL::create('Landing', 'About'); ?>">About</li>
<li><a href="mailto:nicky.leach@nyu.edu">Contact</a></li>
</ul>
示例8: redirect
public static function redirect($controller, $action = null, $args = null, $params = null, $hard = false){
$url = URL::create($controller, $action, $args, $params);
// do actual redirect
if($hard){
header('HTTP/1.1 301 Moved Permanently');
} else {
header('Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0 ');
header('Pragma: no-cache ');
}
header('Location: ' . $url);
exit;
}
示例9: validate
/**
* Validate the requested URL. This will check if a secured hash is provided for the current URI.
*
* @param string|null $secret
* @return bool
*/
public static function validate($secret = null)
{
return URL::create(self::getRequestUri(), $_GET)->isValid($secret);
}