Class

TextHelper

Package: Helper Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Regis VIARRE crowkait@phpboost.com Version: PHPBoost 5.2 - last update: 2018 11 09 Since: PHPBoost 3.0 - 2010 01 24 Contributor: Julien BRISWALTER j1.seth@phpboost.com Contributor: Arnaud GENET elenwii@phpboost.com Contributor: mipel mipel@phpboost.com Located at: helper/TextHelper.class.php

Text helper

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!

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.

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.

public static string
# cut_string( string $string, integer $length )

Cut string to the desired length, ending with the last full word.

public static string
# to_js_string( string $string, string $add_quotes = true )

Exports a variable to be used in a javascript script.

public static string
# to_json_string( string $string, string $add_quotes = true )

Exports a variable to be used in a json javascript script.

public static
# htmlspecialchars( $string, $flags = null, $encoding = 'UTF-8', $double_encode = true )
public static
# htmlspecialchars_decode( $string, $flags = null )
public static
# html_entity_decode( $string, $flags = null, $encoding = 'UTF-8' )
public static
# strtolower( $string )
public static
# strtoupper( $string )
public static
# lcfirst( $string )
public static
# ucfirst( $string )
public static
# strlen( $string )
public static
# strpos( $string, $substring, $offset = '' )
public static
# stripos( $string, $substring, $offset = '' )
public static
# substr( $string, $start, $length = '' )
public static
# mb_substr( $string, $start, $length = '' )
public static
# strrchr( $string, $needle )
public static
# strripos( $string, $needle, $offset = '' )
public static
# strrpos( $string, $needle, $offset = '' )
public static
# strstr( $string, $needle, $before_needle = '' )
public static
# substr_count( $string, $needle, $encoding = '' )
public static
# convert_case( $string, $mode, $encoding = '' )
public static
# serialize( $string )
public static
# serialize_base64( $string )
public static
# unserialize( $string )
public static
# mb_unserialize( $string )
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

Constants summary
boolean HTML_NO_PROTECT
# false
boolean HTML_PROTECT
# true
integer ADDSLASHES_FORCE
# 1
integer ADDSLASHES_NONE
# 2