Class Html
Provides helper methods for dealing with HTML content
Methods summary
public
string
|
#
_( string & $str, boolean $return = false, boolean $preserve_tags = false )
Outputs or returns the given string in HTML safe format, if it exists
Outputs or returns the given string in HTML safe format, if it exists
Parameters
- $str
string $str The string to print, if it exists
- $return
boolean $return True to return the result as a string, else echo the result
- $preserve_tags
boolean $preserve_tags True to preserve tags
Returns
string The result (if $return is set to true)
|
public
string
|
#
safe( string $str, boolean $preserve_tags = false )
Makes a given string HTML safe
Makes a given string HTML safe
Parameters
- $str
string $str The string to make HTML safe
- $preserve_tags
boolean $preserve_tags True to preserve tags
Returns
string The string in HTML safe format
|
public
boolean
|
#
isUtf8( string $str )
Tests whether the given string is in UTF8 format
Tests whether the given string is in UTF8 format
Parameters
- $str
string $str The string to test
Returns
boolean True if it is UTF8, false otherwise
|
public
string
|
#
ifSet( string & $str, string $alt = "" )
Returns the given string as-is, if it exists. This is similar to Html::_(),
except it does not make the string HTML safe, and an alternative value may be
returned if the given $str does not exist. It's useful for passing into methods
that expect raw text.
Returns the given string as-is, if it exists. This is similar to Html::_(),
except it does not make the string HTML safe, and an alternative value may be
returned if the given $str does not exist. It's useful for passing into methods
that expect raw text.
Parameters
- $str
string $str The string to print, if it exists
- $alt
string $alt The alternate string to use if $str is not set
Returns
string The result
See
|
public
string
|
#
concat( mixed $separator = null )
Concatenate multiple strings together, with an optional separator
Concatenate multiple strings together, with an optional separator
Parameters
- $separator
mixed $separator A string to be placed between each element or an array, containing
'start', 'before', 'between', after', and 'end' separators -- all optional
Returns
string The concatenated string
|
public
string
|
#
buildAttributes( array $attributes = null, mixed $glue = " " )
Builds attributes for the current tag. An attribute may be either a string or
an array. In the case of arrays, the elements of the arrays will be concatenated
together using the $glue parameter.
Builds attributes for the current tag. An attribute may be either a string or
an array. In the case of arrays, the elements of the arrays will be concatenated
together using the $glue parameter.
Parameters
- $attributes
array $attributes The attribute keys and values to build
- $glue
Returns
string The key=value attributes
Pararm
string $glue The string to use to concatenate an array of attribute values
together
|
public
string
|
#
addCondition( string $html, string $expression, boolean $hidden = true )
Add conditional operation around a block of HTML
Add conditional operation around a block of HTML
Parameters
- $html
string $html The HTML to wrap an expression around
- $expression
string $expression The expression to use
- $hidden
boolean $hidden True to hide the $html from all browsers by default, false to display by
default
Returns
string The HTML block with the condition wrapped around it
|
public
string
|
#
hyperlink( string $content )
Converts hyperlinks found into HTML
Converts hyperlinks found into HTML
Parameters
- $content
string $content Content containing hyperlinks
Returns
string The content with hyperlinks as HTML
|
Magic methods summary
Properties summary
public
boolean
|
$xhtml |
#
True if requiring XHTML standards, false for traditional HTML
True if requiring XHTML standards, false for traditional HTML
|