Building a String using Concatenation and Ternary Operator
Copy this code and paste it in your HTML
$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
: '') : '';
Report this snippet
Comments
Subscribe to comments