JURI/toString: Difference between revisions
From Joomla! Documentation
m removing red link to edit, no existant pages |
m preparing for archive only |
||
| Line 56: | Line 56: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=toString | category=toString | ||
category=JURI | category=JURI | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 01:14, 25 March 2017
Description
Returns full uri string
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
toString($parts=array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))
| Parameter Name | Default Value | Description |
|---|---|---|
| $parts | array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment') | $parts An array specifying the parts to render |
Returns
string The rendered URI string
Defined in
libraries/joomla/environment/uri.php
Importing
jimport( 'joomla.environment.uri' );
Source Body
function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))
{
$query = $this->getQuery(); //make sure the query is created
$uri = '';
$uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme.'://' : '') : '';
$uri .= in_array('user', $parts) ? $this->_user : '';
$uri .= in_array('pass', $parts) ? (!empty ($this->_pass) ? ':' : '') .$this->_pass. (!empty ($this->_user) ? '@' : '') : '';
$uri .= in_array('host', $parts) ? $this->_host : '';
$uri .= in_array('port', $parts) ? (!empty ($this->_port) ? ':' : '').$this->_port : '';
$uri .= in_array('path', $parts) ? $this->_path : '';
$uri .= in_array('query', $parts) ? (!empty ($query) ? '?'.$query : '') : '';
$uri .= in_array('fragment', $parts)? (!empty ($this->_fragment) ? '#'.$this->_fragment : '') : '';
return $uri;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples