Methods summary
public static
string
|
#
strprotect( string $var, boolean $html_protect = self::HTML_PROTECT, integer $addslashes = self::ADDSLASHES_FORCE )
Protects an input variable. Never trust user input!
Protects an input variable. Never trust user input!
Parameters
- $var
- Variable to protect.
- $html_protect
HTML_PROTECT if you don't accept the HTML code (it will be transformed
by the corresponding HTML entities and won't be considerer by the web browsers).
- $addslashes
- If you want to escape the quotes in the string, use ADDSLASHES_FORCE, if you don't want, use the ADDSLASHES_NONE constant.
Returns
string The protected string.
|
public static
string
|
#
wordwrap_html( string $str, integer $lenght, string $cut_char = '<br />', boolean $cut = true )
Inserts a carriage return every $lenght characters. It's equivalent to wordwrap PHP function but it can deal with the HTML entities.
An entity is coded on several characters and the wordwrap function counts several characters for an entity whereas it represents only one character.
Inserts a carriage return every $lenght characters. It's equivalent to wordwrap PHP function but it can deal with the HTML entities.
An entity is coded on several characters and the wordwrap function counts several characters for an entity whereas it represents only one character.
Parameters
- $str
- The string to wrap.
- $lenght
- The number of characters you want in a line.
- $cut_char
- The character to insert every $lenght characters. The default value is '
', the HTML carriage return tag.
- $cut
- True if you accept that a word would be broken apart, false if you want to cut only on a blank character.
Returns
string The wrapped HTML string.
|
public static
string
|
#
substr_html( string $str, integer $start, integer $end = '' )
Cuts a string containing some HTML code which contains some HTML entities. The substr PHP function considers a HTML entity as several characters.
This function allows you to consider them as only one character.
Cuts a string containing some HTML code which contains some HTML entities. The substr PHP function considers a HTML entity as several characters.
This function allows you to consider them as only one character.
Parameters
- $str
- The string you want to cut.
- $start
If start is non-negative, the returned string will start at the start 'th position in string , counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.
If start is negative, the returned string will start at the start 'th character from the end of string .
If string is less than or equal to start characters long, FALSE will be returned.
- $end
- If length is given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of string ).
Returns
string The sub string.
|
public static
string
|
#
cut_string( string $string, integer $length )
Cut string to the desired length, ending with the last full word.
Cut string to the desired length, ending with the last full word.
Parameters
- $string
- A PHP string to convert to cut
- $length
- The desired length
Returns
string The substring
|
public static
string
|
#
to_js_string( string $string, string $add_quotes = true )
Exports a variable to be used in a javascript script.
Exports a variable to be used in a javascript script.
Parameters
- $string
- A PHP string to convert to a JS one
- $add_quotes
- If true, returned string will be bounded by single quotes
Returns
string The js equivalent string
|
public static
string
|
#
to_json_string( string $string, string $add_quotes = true )
Exports a variable to be used in a json javascript script.
Exports a variable to be used in a json javascript script.
Parameters
- $string
- A PHP string to convert to a json one
- $add_quotes
- If true, returned string will be bounded by double quotes
Returns
string The json equivalent string
|
public static
|
#
htmlspecialchars( $string, $flags = null, $encoding = 'UTF-8', $double_encode = true )
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
#
strpos( $string, $substring, $offset = '' )
|
public static
|
#
stripos( $string, $substring, $offset = '' )
|
public static
|
#
substr( $string, $start, $length = '' )
|
public static
|
|
public static
|
|
public static
|
|
public static
|
#
strrpos( $string, $needle, $offset = '' )
|
public static
|
#
strstr( $string, $needle, $before_needle = '' )
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
boolean
|
#
check_nbr_links( string $contents, integer $max_nbr, boolean $has_html_links = false )
Checks if a string contains less than a defined number of links (used to prevent SPAM).
Checks if a string contains less than a defined number of links (used to prevent SPAM).
Parameters
- $contents
- String in which you want to count the number of links
- $max_nbr
- Maximum number of links accepted.
- $has_html_links
- true if the content is in HTML
Returns
boolean true if there are no too much links, false otherwise.
|
public static
string
|
#
utf8_wordwrap( string $string, integer $width = 75, string $break = "\n", string $cut = true )
Wraps a UTF-8 string to a given number of characters
Wraps a UTF-8 string to a given number of characters
Parameters
- $string
- the input string
- $width
- the column width
- $break
- the line is broken using the optional break parameter
- $cut
- not used for the moment
Returns
string the given string wrapped at the specified column
|