This chapter comment on all the details related to strings, existing functions, and so on.
A string consists of a sequence of characters who are falling between anchors that may include:
– Single Quote ”
If you want for example some “inside quotes in the chain of character is a need for action is called escape a character that is to precede a ie.” Special characters that can appear within a delimitation document are:
No New Line
r Carriage return
t Tabulation horizontal
$ Dollar signs
[0-7] (1.3) ASCII character which coincides with the number octal
x [0-9A-Fa-f] (1.2) ASCII character which coincides with the number hex
The case of embedded document is different from both quotes. His syntax is as follows:
The result is embedded with the text document as shown has been introduced.
The role chr (value) takes us back to a variable rate of the character string table ASCII codes associated with a value that receives as a parameter, the value they pass must be between 0 and 255.
The role ord (chain) takes us back a whole number that corresponds to the ASCII code the first character that receives as a parameter.
— Echo: how to display more jobs. His syntax is as follows: echo “text”;
— Print: This is the most straightforward of all and is responsible for displaying a string on its standard output. It does not support any output format and its syntax is: print (chain);
— Printf (format, [values]); Its operation is the same as above. The only difference is that this supports output formats as its alignment (default on the left), numerical value (minimum number of characters that display), decimal number and type of data whose prospects are:
% Represents the symbol of a percentage
b The argument is treated as No whole and is represented in binary encoding.
c The argument is treated as No whole and shows the character whose ASCII code corresponds to the value.
d The argument is treated as No whole and is represented in part without coding decimal fractional
f The argument is treated as a No-type double and is represented as a decimal floating point without
o The argument is treated as a whole and No coding is represented in octal
s The argument is and represented as a string
x The argument is considered a no-wide and is represented in hexadecimal encoding lowercase
X The argument is considered a no-wide and is represented in hexadecimal encoding uppercase
— Sprintf (format, [values]); their operation is identical to printf. The only thing that the chain resulting from applying a particular format is stored in a variable.
It is sometimes necessary to use those functions to alter the output format of chains. The functions used to modify the format are:
— Chop (chain); Returns the string with white characters and new line Removed
— Ltrim (chain); deletes whites who appear to the right of a string
— Rtrim (chain); deletes whites that appear right in a string
— Trim (chain); deletes whites who appear to the left and right of the string
— Str_pad (chain length, stuffing, place); check if the length is less than the stated value, if so adds necesarios.El characters rather than add can be:
str_pad_left adds right (default option), adds str_pad_right left and str_pad_both added at both ends.
— Str_repeat (characteristic, numero_veces); Repeat a character indicated the number of times
— Strtolower (chain); Pasa whole chain to lowercase letters
— Strtoupper (chain); Pasa whole chain to block letters
— Ucfirst (chain); Pasa capitalized the first character of a string
— Ucwords (chain); He capitalized the first character of each word in the chain
— Str_replace (subcadena1, subcadena2, chain); replaces one word for another in a string
— Strtr (chain, original, translated); Translates certain characters. Example: $ strt person = ($ person, “AEIOU,” “a, e, i, o, u”); in this way would change all accented vowels by vowels without accent.
— Substr_replace (chain, new start, length); replaces a portion of the contents of a chain
Access to content
— Strlen (chain); Indicates No character of a string
— Count_chars (chain, mode); number of repetitions of a character in a chain. The modes are possible:
0 -> Matrix indexed with frequency of all characters of the ASCII code
1 -> Matrix with ASCII characters often greater than 0
2 -> Matrix with characters that do not appear in the chain
3 -> Chain with characters used in the ASCII code
4 -> Chain with characters not used in the ASCII code
— Substr_count (chain, substring); frequency of occurrence of a string
– strchr (chain character); Returns substring beginning at the first appearance of a character indicated
— Strstr (chain, substring); Locate substring within the original string
— Stristr (chain, substring); Like the previous function but without case-sensitive
— Strpos (chain, substring); First occurrence of a string in another
— Strrpos (chain, substring); Last occurrence of a string in another
— Ord (chain); Returns the value of an ASCII character
— Substr (chain, beginning, longitude); portion of text that begins in a position and has a length
— Strcmp (string1, string2); compares two chains being case-sensitive
— Strcasecmp (string1, string2); compares two chains without case-sensitive
— Strncmp (string1, string2, size); Compare N first characters of a string
— Strnatcmp (string1, string2); case sensitive. Compare two chains.
— Strnatcasecmp (string1, string2); not case sensitive. Compare two chains.
— Chunk_split (chain length, separator); Take a string separators and introduces a set distance. It does not alter the original but is a new function.
— Explode (splitter, chain, limit); Lets get an array of strings extracted from the original.
— Implode (separator, elements); Board in a string elements of a matrix using networking as a separator past as a parameter.
— Parse_str (chain); Allows extract and create variables that are part of a chain that corresponds to a query string “received a URL.
* Support for HTML
— Addcslashes (chain, list); Returns a string that has escaped all the characters as a parameter.
— Addslashes (chain); Returns a string that has escaped all characters logical
— Stripcslashes (); and stripslashes (); receive chains that may contain characters of leaks and desescapan
— Quotemeta (chain); Esacapa special characters
— Htmlspecialchars (chain); Conducts conversions as &->&,”->”
— Htmlentities (); Converts all characters to entities html. to become á
— Get_html_translation_table (htmlentities or html_specialchars); Gets terms of translation of each particular character.
— Array_flip (); Exchange keys for the values in associative array.
— Get_meta_tags (filename, include_path); Returns all meta tags containing an HTML.
— Strip_tags (chain, mostrar_tags); Skip labels PHP and HTML, what are the channels of mostrar_tags HTML and PHP should not be omitted in reading.
— N12br (chain); Allows replace line breaks by <br>
— Parse_url (cadena_url); Returns an array of associations with the following fields:
Ip host DNS
User user name
Full Path Path to appeal
query with data query string to appeal
urldecode decodes the information
urlencode Encodes information