create new instance
String
String
(
string $value
)
List of parameters:
Name |
Type |
Description |
$value |
string |
|
Description:
Creates a new string wrapper. The input must be convertable to a string value.
OO-Alias of: addslashes(), addcslashes()
string
&addSlashes
(
[string $charlist = ""]
)
List of parameters:
Name |
Type |
Description |
$charlist |
string |
a string of characters that should be escaped |
Description:
OO-Alias of: $string[$index]
List of parameters:
Name |
Type |
Description |
$index |
int |
position of the character (starting with 0) |
Description:
Returns bool(false) on error. Issues an E_USER_ERROR if $index is of wrong type. Issues an E_USER_NOTICE if $index is out of bounds.
Note that indices are numbered starting with '0'.
clone the string
Description:
compare two strings
int(+1)|int(0)|int(-1)
compareTo
(
string $anotherString
)
List of parameters:
Name |
Type |
Description |
$anotherString |
string |
some other string |
Description:
Returns
- int(-1) if this string < $anotherString
- int(+0) if this string === $anotherString
- int(+1) if this string > $anotherString
Note: This function is case-sensitive.
compare two strings (ignore case)
int(+1)|int(0)|int(-1)
compareToIgnoreCase
(
string $anotherString
)
List of parameters:
Name |
Type |
Description |
$anotherString |
string |
some other string |
Description:
Returns
- int(-1) if this string < $anotherString
- int(+0) if this string === $anotherString
- int(+1) if this string > $anotherString
Note: This function is NOT case-sensitive.
alias of cloneObject()
Description:
decode a string (revertable)
string
&decode
(
string $encoding, [int $style = ENT_COMPAT], [string $charset = ""]
)
List of parameters:
Name |
Type |
Description |
$encoding |
string |
|
$style |
int |
(optional) |
$charset |
string |
(optional) |
Description:
Note: charset applies only to encoding = "entities"
This function is the opposite of "encode()". See "encode()" for details on the available types of encoding.
encoding, or converting a string (revertable)
string
encode
(
string $encoding, [string $style = ENT_COMPAT], [string $charset = ""]
)
List of parameters:
Name |
Type |
Description |
$encoding |
string |
see the list of valid inputs for details |
$style |
string |
used for entity conversion |
$charset |
string |
used for entity conversion |
Description:
Note: charset applies only to encoding = "entities"
Returns an encoded version depending on the type of encoding you choose.
The input value is not case-sensitive.
Note: The results of this function can be reversed using the "decode()" function with the same values. If you are looking for checksums and hashing-methods see the "encrypt" function.
The following values are available.
- unicode: uses utf8_encode(), aliases: "utf", "utf8"
- base64: uses base64_encode()
- url: uses urlencode()
- rawurl: uses rawurlencode()
- entities: uses htmlentities(), uses $style argument
- rot13: does a ROT13 transformation
- quote: quotes meta signs using quotemeta()
- regexp: uses preg_quote(), alias: "regular expression"
hashing function, encryption, transformation (not revertable)
string
&encrypt
(
[string $encryption = "md5"], [string $salt = ""]
)
List of parameters:
Name |
Type |
Description |
$encryption |
string |
see the list of valid inputs for details |
$salt |
string |
only used for certain encryption types |
Description:
Returns an encrypted version depending on the type of encryption you choose.
The input value is not case-sensitive.
Note: The result of this function is alwas irreversible. If you are looking for reversible encryption methods see the "encode" function.
The following values are available.
- crc32: computes the crc32 checksum value of the string
- md5: computes the md5 hash-string (128Bit)
- sha1: computes the sha1 hash-string (160Bit)
- crypt: uses crypt() function, result depending on $salt.
See PHP-Manual for details.
- des: uses DES encryption algorithm
- blowfish: uses BLOWFISH encryption algorithm
- soundex: calculates the soundex hash: While this is not an
encryption algorithm, it is listed here, because it
is uses some sort of irreversible hashing and thus
won't fit to encoding()
- metaphone:calculates the metaphone hash: While this is not an
encryption algorithm, it is listed here, for the
same reason as "soundex". Note: uses the argument
$salt as second argument for metaphone() if $salt
is a numeric value, that can be converted to int.
- any of the encryption types supported by the PHP
"hash()" function introduced as of PHP 5.1.2
- xor: XOR is a simple revertable block chiffre.
Use $salt string as password to encrypt the clear
text. Call encrypt() with the same arguments again
to revert the ciphered text back to clear text.
Note that the security of XOR and all other simple
block chiffres depend on the length and security
off your password. To be really secure your password
needs to be minimum as long as the clear text, which
is not always praticable.
This method issues an E_USER_NOTICE and returns the integer constant STRING_UNSUPPORTED_ENCRYPTION if the $encryption parameter has an invalid value.
test two strings for equality
bool
equals
(
mixed $something
)
List of parameters:
Name |
Type |
Description |
$something |
mixed |
some object that should be compared |
Description:
Returns
- bool(true) if and only if the input is of type string and
string representation of the value of this object and the input string are the same,
or the input is an object of the same type and the string values of both are equal
- bool(false) otherwise
Note: this is unlike the PHP code ($string == $something) where you might accidently run into comparision in e.g. a boolean context.
Redefinition of: Object::equals()
get string value
string
get
()
Description:
Unboxing the object. This function returns the scalar string value of the object.
convert to html entities
string
htmlEntities
(
string $input
)
List of parameters:
Name |
Type |
Description |
$input |
string |
some string |
Description:
convert html special characters
string
htmlSpecialChars
(
string $string, [int $quoteStyle = ENT_COMPAT], [string $charset = 'ISO-8859-1'], [bool $doubleEncode = true]
)
List of parameters:
Name |
Type |
Description |
$string |
string |
text to encode |
$quoteStyle |
int |
ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES |
$charset |
string |
e.g. UTF-8 or ISO-8859-1 |
$doubleEncode |
bool |
set to true to avoid double encoded string |
Description:
This function is much like the original htmlspecialchars() function, but it enables you to use the argument $doubleEncode, which was introduced in PHP 5.2.3 even when running on PHP 4.
If $doubleEncode is set to false, the function will not encode existing HTML entities. In PHP 5.2.3 and beyound the original function is used. In any previous version, that does not have this parameter, the behavior is emulated.
get position of first occurence of a needle inside the string
int
indexOf
(
string $needle, int $offset
)
List of parameters:
Name |
Type |
Description |
$needle |
string |
|
$offset |
int |
|
Description:
Returns character-offset of first occurence of $needle within this string. Indices starting with int(0).
Returns Java-style int(-1) if $needle is not found, NOT Php-style bool(false). This is because int(0) and bool(false) might get mixed by accident.
So while if
(strpos($string, $needle) ==
0))
will return true, even if $needle is not found, the test
if ($string->indexOf($needle) ==
0)
will return false if $needle is not found and true if and only if $string starts with the string $needle.
get the length of the string
int
length
()
Description:
Returns the number of characters in the string.
match string against regular expression
array|bool(false)
match
(
string $regularExpression
)
List of parameters:
Name |
Type |
Description |
$regularExpression |
string |
|
Description:
Matches this string against a given Perl-compatible regular expression. Returns an array containing the FIRST set of matches or bool(false) if the regular expression did not match at all.
match string against regular expression (return all results)
array|bool(false)
matchAll
(
string $regularExpression
)
List of parameters:
Name |
Type |
Description |
$regularExpression |
string |
|
Description:
Matches this string against a given Perl-compatible regular expression. Returns an array containing ALL the matches or bool(false) if the regular expression did not match at all.
OO-Alias of: stripslashes(), stripcslashes()
string
&removeSlashes
(
string $charlist
)
List of parameters:
Name |
Type |
Description |
$charlist |
string |
a string of characters that should be unescaped |
Description:
replace a needle with a substitute
int
replace
(
string $needle, [string $substitute = ""]
)
List of parameters:
Name |
Type |
Description |
$needle |
string |
|
$substitute |
string |
(optional) |
Description:
This will replace all entities of $needle with $substitute. Returns the number of times $needle is replaced.
replace a substring by using a regular expression
int
replaceRegExp
(
string $regularExpression, [string $substitute = ""], [int $limit = -1]
)
List of parameters:
Name |
Type |
Description |
$regularExpression |
string |
|
$substitute |
string |
(optional) |
$limit |
int |
(optional) must be a positive integer > 0, defaults to -1 (no limit) |
Description:
This will replace all hits of the Perl-compatible $regularExpression with $substitute.
Returns the number of times $needle is replaced.
reverse the string value
string
&reverse
()
Description:
set string value
string
set
(
string $value
)
List of parameters:
Name |
Type |
Description |
$value |
string |
a new string value |
Description:
Assigns a new value to the object. Returns the old value.
shuffle the string's characters
string
&shuffle
()
Description:
convert string to an array
array
split
(
string $separator, int $limit
)
List of parameters:
Name |
Type |
Description |
$separator |
string |
|
$limit |
int |
|
Description:
convert string to an array by using regular expression to find a speratator
array
splitRegExp
(
string $separator, int $limit
)
List of parameters:
Name |
Type |
Description |
$separator |
string |
|
$limit |
int |
|
Description:
extract a substring
string
&substring
(
int $start, int $length
)
List of parameters:
Name |
Type |
Description |
$start |
int |
|
$length |
int |
(optional) |
Description:
Returns a substring beginning at character-offset $start with $length characters. See PHP-Manual "string functions" "substr()" for details.
return value as boolean
bool
toBool
()
Description:
Returns a boolean value depending on the value of the string.
- string("false") returns bool(false)
- string("true") returns bool(true)
- any other value returns a boolean value
depending on the result of PHP's
internal conversion mechanism,
BUT also issues an E_USER_NOTICE for on
an invalid string to bool conversion
Note: If you just want to check wether a string is empty or not, use $string->equals("") instead.
return value as float
float|bool(false)
toFloat
()
Description:
Converts the string value to a float and returns it. Returns bool(false) if the string is not numeric.
return value as int
int|bool(false)
toInt
()
Description:
Converts the string value to an integer and returns it. Returns bool(false) if the string is not numeric.
return a lower-cased version of the string
string
&toLowerCase
()
Description:
Alias of: String::get()
void
toString
()
Description:
return a upper-cased version of the string
string
&toUpperCase
()
Description:
OO-Alias of: trim(), chop()
string
&trim
()
Description:
wrap a long text
string
&wrap
(
int $width, [string $break = ""], [bool $cut = false]
)
List of parameters:
Name |
Type |
Description |
$width |
int |
|
$break |
string |
|
$cut |
bool |
|
Description:
inherited from base classes
Inherited From Object