本文整理汇总了PHP中http_build_url函数的典型用法代码示例。如果您正苦于以下问题:PHP http_build_url函数的具体用法?PHP http_build_url怎么用?PHP http_build_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了http_build_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: generateCallbackUrl
/**
* Generate the callback URL to be notified when a payment is received.
* @param string $url
* @return string
*/
public function generateCallbackUrl($url)
{
if (!is_string($url)) {
throw new \InvalidArgumentException('$url is not string');
}
return http_build_url($url, array('query' => 'secret=' . $this->getSecretParameter()), HTTP_URL_STRIP_AUTH | HTTP_URL_JOIN_PATH | HTTP_URL_JOIN_QUERY | HTTP_URL_STRIP_FRAGMENT);
}
开发者ID:mikoweb,项目名称:vsymfo-payment-blockchain-bundle,代码行数:12,代码来源:BlockchainClient.php
示例2: test_wwwRedirect
/**
* Test that www/no-www is handled correctly
*
* If the site is using a www URL, then no-www should redirect to www.
* If the site is using a non-www URL, then www should redirect to no-www.
*
* The redirect should be done with 301 permanent redirect status
* code. And once the user follows the redirect, he should end up on
* the correct page.
*/
public function test_wwwRedirect()
{
$components = $this->components;
$pos = strpos($components['host'], 'www.');
if ($pos === false || $pos > 0) {
$components['host'] = 'www.' . $components['host'];
} else {
$components['host'] = substr($components['host'], 4);
}
$wwwUrl = http_build_url($components);
try {
$res = $this->client->get($wwwUrl, ['allow_redirects' => false, 'timeout' => $this->timeout]);
$statusCode = $res->getStatusCode();
} catch (\Exception $e) {
$this->fail("Failed fetching URL [{$wwwUrl}] : " . $e->getMessage());
}
$this->assertEquals(301, $statusCode, "The www/no-www redirect did not return 301 status code");
try {
$res = $this->client->get($wwwUrl, ['timeout' => $this->timeout]);
$statusCode = $res->getStatusCode();
} catch (\Exception $e) {
$this->fail("Failed fetching URL [{$wwwUrl}] : " . $e->getMessage());
}
$this->assertEquals(200, $statusCode, "The www/no-www redirect did not end up in 200 status code");
}
开发者ID:mamchenkov,项目名称:Web-Tester,代码行数:35,代码来源:BasicTest.php
示例3: _buildURI
private function _buildURI($append_path = null, $append_query = null)
{
$uri = $this->_uri_pieces;
if (isset($append_path)) {
if (is_array($append_path)) {
$uri['path'] = array_merge($uri['path'], $append_path);
} else {
$uri['path'][] = $append_path;
}
}
if (!empty($uri['path'])) {
$uri['path'] = '/' . implode('/', $uri['path']);
}
if (isset($append_query) && is_array($append_query)) {
foreach ($append_query as $key => $value) {
if (is_bool($value)) {
$append_query[$key] = $this->_boolString($value);
}
}
if (!empty($uri['query'])) {
$uri['query'] = array_merge($uri['query'], $append_query);
} else {
$uri['query'] = $append_query;
}
}
if (!empty($uri['query'])) {
$uri['query'] = http_build_query($uri['query']);
}
return http_build_url('http://localhost/', $uri);
}
开发者ID:WheresAlice,项目名称:Cushion,代码行数:30,代码来源:cushion.class.php
示例4: __construct
public function __construct()
{
parent::__construct();
$this->load->model('visual_themes')->library('template');
// Determine the current visual theme.
if ($this->input->get('theme') != '' && $this->input->method() == 'get' && !$this->input->is_ajax_request()) {
$theme = (string) $this->input->get('theme');
$this->visual_themes->set_current($theme);
parse_str(parse_url(CURRENT_URL, PHP_URL_QUERY), $query);
unset($query['theme']);
redirect(http_build_url(current_url(), array('query' => http_build_query($query))));
}
$this->template->set_theme($this->visual_themes->get_current());
$default_title = config_item('default_title');
$default_description = config_item('default_description');
$default_keywords = config_item('default_keywords');
if ($default_title != '') {
$this->template->title($default_title);
}
if ($default_description != '') {
$this->template->set_metadata('description', $default_description);
}
if ($default_keywords != '') {
$this->template->set_metadata('keywords', $default_keywords);
}
$this->template->set_breadcrumb('<i class="fa fa-home"></i> ' . $this->lang->line('ui_home'), site_url());
}
开发者ID:acamboy,项目名称:starter-public-edition-3,代码行数:27,代码来源:Base_Controller.php
示例5: create
/**
* Creates a url with the given uri, including the base url
*
* @param string $uri
* @param array $variables
* @param array $getVariables
* @param boolean $secure
*
* @return string
*/
public static function create($uri = null, $variables = [], $getVariables = [], $secure = null)
{
$url = '';
$uri = $uri ?: static::string();
// If the given uri is not a full URL
if (!preg_match("#^(http|https|ftp)://#i", $uri)) {
$url .= \Config::get('baseUrl');
if ($index_file = \Config::get('indexFile')) {
$url .= $index_file . '/';
}
}
$url .= ltrim($uri, '/');
// Add a url_suffix if defined and the url doesn't already have one
if (substr($url, -1) != '/' and (($suffix = strrchr($url, '.')) === false or strlen($suffix) > 5)) {
\Config::get('url_suffix') and $url .= \Config::get('url_suffix');
}
if (!empty($get_variables)) {
$char = strpos($url, '?') === false ? '?' : '&';
if (is_string($get_variables)) {
$url .= $char . str_replace('%3A', ':', $get_variables);
} else {
$url .= $char . str_replace('%3A', ':', http_build_query($get_variables));
}
}
array_walk($variables, function ($val, $key) use(&$url) {
$url = str_replace(':' . $key, $val, $url);
});
is_bool($secure) and $url = http_build_url($url, array('scheme' => $secure ? 'https' : 'http'));
return $url;
}
开发者ID:fuelphp,项目名称:legacy,代码行数:40,代码来源:Uri.php
示例6: _processAnchors
protected function _processAnchors($content, $url, $depth)
{
$dom = new DOMDocument('1.0');
@$dom->loadHTML($content);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $element) {
$href = $element->getAttribute('href');
if (0 !== strpos($href, 'http')) {
$path = '/' . ltrim($href, '/');
if (extension_loaded('http')) {
$href = http_build_url($url, array('path' => $path));
} else {
$parts = parse_url($url);
$href = $parts['scheme'] . '://';
if (isset($parts['user']) && isset($parts['pass'])) {
$href .= $parts['user'] . ':' . $parts['pass'] . '@';
}
$href .= $parts['host'];
if (isset($parts['port'])) {
$href .= ':' . $parts['port'];
}
$href .= $path;
}
}
// Crawl only link that belongs to the start domain
$this->crawl_page($href, $depth - 1);
}
}
开发者ID:jackmcdowell,项目名称:domainEmailCrawler,代码行数:28,代码来源:crawler.php
示例7: get
/**
* Creates a URL for requesting a custom user photo.
*/
public function get($photo, $size = null, $default_image = null, $force_default_image = null)
{
$url = $this->base_url . 'avatar/' . $photo;
$query = array();
$size = (int) $size;
if ($size <= 0) {
$size = $this->image_size;
}
if ($size > 0) {
$query['s'] = $size;
}
if (isset($default_image)) {
$default_image = (string) $default_image;
} else {
$default_image = $this->default_image;
}
if ($default_image != '') {
$query['d'] = $default_image;
}
if (isset($force_default_image)) {
$force_default_image = !empty($force_default_image);
} else {
$force_default_image = $this->force_default_image;
}
if ($force_default_image) {
$query['f'] = 'y';
}
if (!empty($query)) {
$url = http_build_url($url, array('query' => http_build_query($query)));
}
return $url;
}
开发者ID:aslijiasheng,项目名称:ciFramework,代码行数:35,代码来源:Custom_user_photo.php
示例8: cf_http_build_url
/**
* Wrapper for "http_build_url" -- will use http_build_url() if it exists, if not will do same thing.
*
* See: http://php.net/manual/en/function.http-build-query.php
*
* @param $url
* @param array $parts
* @param int $flags
* @param bool|false $new_url
*
* @return string
*/
function cf_http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new_url = false)
{
if (function_exists('http_build_url')) {
return http_build_url($url, $parts, $flags, $new_url);
}
$keys = array('user', 'pass', 'port', 'path', 'query', 'fragment');
if ($flags & HTTP_URL_STRIP_ALL) {
$flags |= HTTP_URL_STRIP_USER;
$flags |= HTTP_URL_STRIP_PASS;
$flags |= HTTP_URL_STRIP_PORT;
$flags |= HTTP_URL_STRIP_PATH;
$flags |= HTTP_URL_STRIP_QUERY;
$flags |= HTTP_URL_STRIP_FRAGMENT;
} elseif ($flags & HTTP_URL_STRIP_AUTH) {
$flags |= HTTP_URL_STRIP_USER;
$flags |= HTTP_URL_STRIP_PASS;
}
// Parse the original URL
$parse_url = parse_url($url);
// Scheme and Host are always replaced
if (isset($parts['scheme'])) {
$parse_url['scheme'] = $parts['scheme'];
}
if (isset($parts['host'])) {
$parse_url['host'] = $parts['host'];
}
if ($flags & HTTP_URL_REPLACE) {
foreach ($keys as $key) {
if (isset($parts[$key])) {
$parse_url[$key] = $parts[$key];
}
}
} else {
if (isset($parts['path']) && $flags & HTTP_URL_JOIN_PATH) {
if (isset($parse_url['path'])) {
$parse_url['path'] = rtrim(str_replace(basename($parse_url['path']), '', $parse_url['path']), '/') . '/' . ltrim($parts['path'], '/');
} else {
$parse_url['path'] = $parts['path'];
}
}
if (isset($parts['query']) && $flags & HTTP_URL_JOIN_QUERY) {
if (isset($parse_url['query'])) {
$parse_url['query'] .= '&' . $parts['query'];
} else {
$parse_url['query'] = $parts['query'];
}
}
}
foreach ($keys as $key) {
if ($flags & (int) constant('HTTP_URL_STRIP_' . strtoupper($key))) {
unset($parse_url[$key]);
}
if (isset($parse_url[$key]) && is_array($parse_url[$key])) {
$parse_url[$key] = http_build_query($parse_url[$key]);
}
}
$new_url = $parse_url;
return (isset($parse_url['scheme']) ? $parse_url['scheme'] . '://' : '') . (isset($parse_url['user']) ? $parse_url['user'] . (isset($parse_url['pass']) ? ':' . $parse_url['pass'] : '') . '@' : '') . (isset($parse_url['host']) ? $parse_url['host'] : '') . (isset($parse_url['port']) ? ':' . $parse_url['port'] : '') . (isset($parse_url['path']) ? $parse_url['path'] : '') . (isset($parse_url['query']) ? '?' . $parse_url['query'] : '') . (isset($parse_url['fragment']) ? '#' . $parse_url['fragment'] : '');
}
开发者ID:conscious-jp,项目名称:website,代码行数:71,代码来源:compat.php
示例9: joinURL
public static function joinURL($parts)
{
// imgix idiosyncracy for signing URLs when only the signature exists. Our query string must begin with '?&s='
if (substr($parts['query'], 0, 2) === "s=") {
$parts['query'] = "&" . $parts['query'];
}
return http_build_url($parts);
}
开发者ID:prawee,项目名称:imgix-php,代码行数:8,代码来源:UrlHelper.php
示例10: action_chat
public function action_chat()
{
$this->template->content = \View::forge('member/chat');
$config = Config::get('db.nodejs.chat', array());
$host = empty($config['host']) ? Config::get('base_url') : $config['host'];
$port = empty($config['port']) ? 0 : (int) $config['port'];
$this->template->content->chat_url = $port ? http_build_url('/', array('host' => $host, 'port' => $port)) : $host;
}
开发者ID:jkapelner,项目名称:chatroom-web-server,代码行数:8,代码来源:member.php
示例11: __construct
public function __construct()
{
parent::__construct();
$this->load->language('welcome')->library('curl');
$title = 'Lex Parser Test';
$this->template->append_title($title)->set_breadcrumb($title, http_build_url(site_url('playground/lex-parser'), array('query' => http_build_query(array('q_1' => 'query_param_1', 'q_2' => 'query_param_2')))));
$this->registry->set('nav', 'playground/lex');
}
开发者ID:roniwahyu,项目名称:starter-public-edition-3,代码行数:8,代码来源:Lex_parser_controller.php
示例12: validate_url
function validate_url($variable, $options = null)
{
$parsed_url = parse_url($variable);
if (empty($parsed_url) || !is_array($parsed_url) || empty($parsed_url['host'])) {
return false;
}
$parsed_url['host'] = idn_to_ascii($parsed_url['host']);
return (bool) filter_var(http_build_url($parsed_url), FILTER_VALIDATE_URL, $options);
}
开发者ID:lifeofguenter,项目名称:validate_rapper,代码行数:9,代码来源:validate.php
示例13: authenticated_url
function authenticated_url($url)
{
// we are using HTTP authentication in this example
// if using sessions you'll want to put the session name and ID into the query string instead
$parts = array();
$parts['user'] = $_SERVER['PHP_AUTH_USER'];
$parts['pass'] = $_SERVER['PHP_AUTH_PW'];
return http_build_url($url, $parts);
}
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:9,代码来源:authutils.php
示例14: buildURL
public function buildURL()
{
$params = [];
foreach ($this->paramsName as $key => $_name) {
$params[$_name] = $this->{$key};
}
$this->url = ($this->region ? "{$this->region}." : "") . "{$this->site}/" . ($this->mainCategory ? "/{$this->mainCategory}/" : "") . ($this->childCategory ? "/{$this->childCategory}/" : "");
return http_build_url($this->url, $params);
}
开发者ID:sonrac,项目名称:Parser,代码行数:9,代码来源:Parser.php
示例15: getDomainLink
/**
* Returns domain link from url.
* @param $url
* @return string
*/
protected function getDomainLink($url)
{
$parsedLink = parse_url($url);
if ($parsedLink == false) {
return "";
}
$domainLink = http_build_url($url, $parsedLink, HTTP_URL_STRIP_PATH | HTTP_URL_STRIP_QUERY | HTTP_URL_STRIP_FRAGMENT);
return $domainLink;
}
开发者ID:janci,项目名称:sitemap-generator,代码行数:14,代码来源:SitemapGenerator.php
示例16: getAbsoluteURL
public function getAbsoluteURL($source_url, $relative_url)
{
$url_parts = parse_url($relative_url);
if (array_key_exists('scheme', $url_parts)) {
return $relative_url;
}
$absolute = http_build_url($source_url, $url_parts, HTTP_URL_JOIN_PATH);
return $absolute;
}
开发者ID:ronnywang,项目名称:TWLegislativeYuanData,代码行数:9,代码来源:crawler.php
示例17: Nice
/**
* Remove ugly parts of a url to make it nice
*/
public function Nice()
{
if ($this->value && ($parts = parse_url($this->URL()))) {
$remove = array('scheme', 'user', 'pass', 'port', 'query', 'fragment');
foreach ($remove as $part) {
unset($parts[$part]);
}
return rtrim(http_build_url($parts), "/");
}
}
开发者ID:burnbright,项目名称:silverstripe-externalurlfield,代码行数:13,代码来源:ExternalURL.php
示例18: _client_pmaSetLanguage
/**
* Set PhpMyAdmin language according language set in panel
*
* Note: If panel language doesn't match any language available for PMA, language
* is set to English (en).
*
* @access private
* @param string $location PMA URI location
* @return string PMA URI location
*/
function _client_pmaSetLanguage($location)
{
/** @var Zend_Translate_Adapter $translator */
$translator = iMSCP_Registry::get('translator')->getAdapter();
$uriComponents = parse_url($location);
parse_str($uriComponents['query'], $queryParts);
$queryParts['lang'] = substr($translator->getLocale(), 0, 2);
$uriComponents['query'] = http_build_query($queryParts);
return http_build_url($location, $uriComponents);
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:20,代码来源:pma_auth.php
示例19: image_process_nowm
function image_process_nowm($src, $width = null, $height = null, $no_crop = null, $keep_canvas_size = null)
{
if ($no_crop !== null) {
$no_crop = empty($no_crop) ? 0 : 1;
}
if ($keep_canvas_size !== null) {
$keep_canvas_size = empty($keep_canvas_size) ? 0 : 1;
}
return http_build_url(site_url('playground/image-process-nowm'), array('query' => http_build_query(array('src' => $src, 'w' => $width, 'h' => $height, 'no_crop' => $no_crop, 'keep_canvas_size' => $keep_canvas_size))), HTTP_URL_JOIN_QUERY);
}
开发者ID:Qnatz,项目名称:starter-public-edition-4,代码行数:10,代码来源:colorbox.php
示例20: __construct
/**
* Class constructor
*
* Sets the $config data from the primary config.php file as a class variable.
*
* @return void
*/
public function __construct()
{
$this->config =& get_config();
global $DETECT_URL;
// Set the base_url automatically if none was provided
if (empty($this->config['base_url'])) {
$this->set_item('base_url', $DETECT_URL['base_url']);
} else {
$this->set_item('base_url', http_build_url($this->config['base_url'], array('scheme' => $DETECT_URL['server_protocol'], 'port' => $DETECT_URL['port'])));
}
if (!defined('BASE_URL')) {
define('BASE_URL', $this->add_slash($this->base_url()));
}
if (!defined('BASE_URI')) {
define('BASE_URI', $DETECT_URL['base_uri']);
}
if (!defined('SERVER_URL')) {
define('SERVER_URL', $this->add_slash(substr(BASE_URL, 0, strlen(BASE_URL) - strlen(BASE_URI))));
}
if (!defined('SITE_URL')) {
define('SITE_URL', $this->add_slash($this->site_url()));
}
if (!defined('SITE_URI')) {
define('SITE_URI', '/' . str_replace(SERVER_URL, '', SITE_URL));
}
if (!defined('CURRENT_URI')) {
define('CURRENT_URI', $DETECT_URL['current_uri']);
}
if (!defined('CURRENT_URL')) {
define('CURRENT_URL', rtrim(SERVER_URL, '/') . CURRENT_URI);
}
// Added by Ivan Tcholakov, 26-DEC-2013.
// See https://github.com/EllisLab/CodeIgniter/issues/2792
if (!defined('IS_UTF8_CHARSET')) {
define('IS_UTF8_CHARSET', strtolower($this->config['charset']) === 'utf-8');
}
//
// Common Purpose File System Repositories
$public_upload_path = $this->add_slash(isset($this->config['public_upload_path']) && $this->config['public_upload_path'] != '' ? $this->config['public_upload_path'] : FCPATH . 'upload/');
$this->set_item('public_upload_path', $public_upload_path);
if (!defined('PUBLIC_UPLOAD_PATH')) {
define('PUBLIC_UPLOAD_PATH', $public_upload_path);
}
$public_upload_url = $this->add_slash(isset($this->config['public_upload_url']) && $this->config['public_upload_url'] != '' ? str_replace('{base_url}', BASE_URL, $this->config['public_upload_url']) : BASE_URL . 'upload/');
$this->set_item('public_upload_url', $public_upload_url);
if (!defined('PUBLIC_UPLOAD_URL')) {
define('PUBLIC_UPLOAD_URL', $public_upload_url);
}
$platform_upload_path = $this->add_slash(isset($this->config['platform_upload_path']) && $this->config['platform_upload_path'] != '' ? $this->config['platform_upload_path'] : PLATFORMPATH . 'upload/');
$this->set_item('platform_upload_path', $platform_upload_path);
if (!defined('PLATFORM_UPLOAD_PATH')) {
define('PLATFORM_UPLOAD_PATH', $platform_upload_path);
}
log_message('info', 'Config Class Initialized');
}
开发者ID:Balamir,项目名称:starter-public-edition-3,代码行数:62,代码来源:MY_Config.php
注:本文中的http_build_url函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论