YANA 4 PHP Framework
Docs For Class String_type
«datatype» String_type
This is a OO-wrapper for the scalar string type of PHP. This implementation is compatible with PHP 4 and 5.
Note: this class is still under developement. Use as see fit but be aware of possible changes in the future.
Located in /includes/class_string_type.php
create new instance
Creates a new string wrapper. The input must be convertable to a string value.
Name | Type | Description |
---|---|---|
$stringValue | string |
OO-Alias of: addslashes(), addcslashes()
Name | Type | Description |
---|---|---|
$charlist | string | (optional) |
OO-Alias of: $string[$index]
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'.
Name | Type | Description |
---|---|---|
$index | int | (optional) |
compare two strings
Returns
Note: This function is case-sensitive.
Name | Type | Description |
---|---|---|
$anotherString | string |
compare two strings (ignore case)
Returns
Note: This function is NOT case-sensitive.
Name | Type | Description |
---|---|---|
$anotherString | string |
decode a string (revertable)
Note: charset applies only to encoding = "entities"
This function is the opposite of "encode()". See "encode()" for details on the available types of encoding.
Name | Type | Description |
---|---|---|
$encoding | string | |
$style | int | (optional) |
$charset | string | (optional) |
encode a string (revertable)
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.
Name | Type | Description |
---|---|---|
$encoding | string | see the list of valid inputs for details |
$style | string | (optional) |
$charset | string | (optional) |
encrypt or transform a string (not revertable)
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.
Name | Type | Description |
---|---|---|
$encryption | string | (optional) see the list of valid inputs for details |
$salt | string | (optional) only used for certain encryption types |
test two strings for equality
Returns
Note: this is unlike the PHP code ($string == $something) where you might accidently run into comparision in e.g. a boolean context.
Name | Type | Description |
---|---|---|
$something | mixed |
get string value
Unboxing the object. This function returns the scalar string value of the object.
convert to html entities
Name | Type | Description |
---|---|---|
$input | string |
get position of first occurence of a needle inside the string
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
will return true, even if $needle is not found, the test
- (strpos($string, $needle) == 0))
will return false if $needle is not found and true if and only if $string starts with the string $needle.
- if ($string->indexOf($needle) == 0)
Name | Type | Description |
---|---|---|
$needle | string | |
$offset | int | (optional) |
get the length of the string
match string against regular expression
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.
Name | Type | Description |
---|---|---|
$regularExpression | string |
match string against regular expression (return all results)
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.
Name | Type | Description |
---|---|---|
$regularExpression | string |
OO-Alias of: stripslashes(), stripcslashes()
Name | Type | Description |
---|---|---|
$charlist | string | (optional) |
replace a needle with a substitute
Name | Type | Description |
---|---|---|
$needle | string | |
$substitute | string | (optional) |
replace a substring by using a regular expression
Name | Type | Description |
---|---|---|
$needle | string | |
$substitute | string | (optional) |
$limit | int | (optional) must be a positive integer > 0, defaults to -1 (no limit) |
reverse the string value
set string value
Assigns a new value to the object. Returns the old value.
Name | Type | Description |
---|---|---|
$new_value | string |
shuffle the string's characters
convert string to an array
Name | Type | Description |
---|---|---|
$separator | string | |
$limit | int | (optional) |
convert string to an array by using regular expression to find a speratator
Name | Type | Description |
---|---|---|
$separator | string | |
$limit | int | (optional) |
extract a substring
Returns a substring beginning at character-offset $start with $length characters. See PHP-Manual "string functions" "substr()" for details.
Name | Type | Description |
---|---|---|
$start | int | |
$length | int | (optional) |
return value as boolean
Returns a boolean value depending on the value of the string.
Note: If you just want to check wether a string is empty or not, use $string->equals("") instead.
return value as float
Converts the string value to a float and returns it. Returns bool(false) if the string is not numeric.
return value as int
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
Alias of: String_type::get()
return a upper-cased version of the string
OO-Alias of: trim(), chop()
wrap a long text
Note: THIS FUNCTION IS NOT BINARY-SAFE!
Name | Type | Description |
---|---|---|
$width | int | (optional) |
$break | string | (optional) |
$cut | bool | (optional) |
Documentation generated on Sat, 16 Sep 2006 17:06:06 +0200 by phpDocumentor 1.3.0RC4