diff --git a/reference/strings/functions/addcslashes.xml b/reference/strings/functions/addcslashes.xml index 423b776b6e..09d98e2cae 100644 --- a/reference/strings/functions/addcslashes.xml +++ b/reference/strings/functions/addcslashes.xml @@ -1,13 +1,13 @@ - - + addcslashes Quote string with slashes in a C style - - Description + + + &reftitle.description; stringaddcslashes stringstr @@ -15,21 +15,89 @@ Returns a string with backslashes before characters that are - listed in charlist parameter. If - charlist contains characters - \n, \r etc., they are - converted in C-like style, while other non-alphanumeric characters - with ASCII codes lower than 32 and higher than 126 converted to - octal representation. + listed in charlist parameter. + + + + &reftitle.parameters; - Be careful if you choose to escape characters 0, a, b, f, n, r, - t and v. They will be converted to \0, \a, \b, \f, \n, \r, \t - and \v. - In PHP \0 (NULL), \r (carriage return), \n (newline) and \t (tab) - are predefined escape sequences, while in C all of these are - predefined escape sequences. + + + str + + + The string to be escaped. + + + + + charlist + + + A list of characters to be escaped. If + charlist contains characters + \n, \r etc., they are + converted in C-like style, while other non-alphanumeric characters + with ASCII codes lower than 32 and higher than 126 converted to + octal representation. + + + When you define a sequence of characters in the charlist argument + make sure that you know what characters come between the + characters that you set as the start and end of the range. + + + +]]> + + + Also, if the first character in a range has a higher ASCII value + than the second character in the range, no range will be + constructed. Only the start, end and period characters will be + escaped. Use the ord function to find the + ASCII value for a character. + + + +]]> + + + + + Be careful if you choose to escape characters 0, a, b, f, n, r, + t and v. They will be converted to \0, \a, \b, \f, \n, \r, \t + and \v. + In PHP \0 (NULL), \r (carriage return), \n (newline) and \t (tab) + are predefined escape sequences, while in C all of these are + predefined escape sequences. + + + + + + + + &reftitle.returnvalues; + + Returns the escaped string. + + + + + &reftitle.examples; charlist like "\0..\37", which would escape all characters with ASCII code between 0 and 31. @@ -44,47 +112,21 @@ $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377"); + + + + &reftitle.seealso; - When you define a sequence of characters in the charlist argument - make sure that you know what characters come between the - characters that you set as the start and end of the range. - - - -]]> - - - Also, if the first character in a range has a higher ASCII value - than the second character in the range, no range will be - constructed. Only the start, end and period characters will be - escaped. Use the ord function to find the - ASCII value for a character. - - - -]]> - - - - - See also stripcslashes, - stripslashes, - addslashes, - htmlspecialchars, and - quotemeta. + + stripcslashes + stripslashes + addslashes + htmlspecialchars + quotemeta + + - + addslashes Quote string with slashes - - Description + + + &reftitle.description; stringaddslashes stringstr @@ -42,6 +42,33 @@ get_magic_quotes_gpc may come in handy for checking this. + + + + &reftitle.parameters; + + + + str + + + The string to be escaped. + + + + + + + + + &reftitle.returnvalues; + + Returns the escaped string. + + + + + &reftitle.examples; An <function>addslashes</function> example @@ -57,15 +84,22 @@ echo addslashes($str); + + + + &reftitle.seealso; - See also stripslashes, - stripcslashes, - addcslashes, - htmlspecialchars, - quotemeta, and - get_magic_quotes_gpc. + + stripcslashes + stripslashes + addcslashes + htmlspecialchars + quotemeta + get_magic_quotes_gpc + + - + bin2hex Convert binary data into hexadecimal representation - - Description + + + &reftitle.description; stringbin2hex stringstr @@ -17,10 +17,41 @@ of str. The conversion is done byte-wise with the high-nibble first. + + + + &reftitle.parameters; - See also pack and unpack. + + + str + + + A character. + + + + + + + &reftitle.returnvalues; + + Returns the hexadecimal representation of the given string. + + + + + &reftitle.seealso; + + + pack + unpack + + + + - + chop @@ -13,6 +12,10 @@ &info.function.alias; rtrim. + + + + &reftitle.notes; chop is different than the Perl @@ -21,6 +24,7 @@ + - + chr Return a specific character - - Description + + + &reftitle.description; stringchr intascii @@ -15,6 +15,38 @@ Returns a one-character string containing the character specified by ascii. + + + This function complements ord. + + + + + &reftitle.parameters; + + + + ascii + + + The ascii code. + + + + + + + + + &reftitle.returnvalues; + + Returns the specified character. + + + + + &reftitle.examples; + <function>chr</function> example @@ -31,16 +63,18 @@ $str = sprintf("The string ends in escape: %c", 27); + + + + &reftitle.seealso; - You can find an ASCII-table over here: &url.asciitable;. - - - This function complements ord. See also - sprintf with a format string of - %c. + + sprintf with a format string of %c + An ASCII-table + + - + chunk_split Split a string into smaller chunks - - Description + + + &reftitle.description; stringchunk_split stringbody @@ -17,9 +17,53 @@ Can be used to split a string into smaller chunks which is useful for e.g. converting base64_encode output to match RFC - 2045 semantics. It inserts end (defaults to - "\r\n") every chunklen characters (defaults to - 76). It returns the new string leaving the original string untouched. + 2045 semantics. It inserts end every + chunklen characters. + + + + + &reftitle.parameters; + + + + body + + + The string to be chunked. + + + + + chunklen + + + The chunk length. Defaults to 76. + + + + + end + + + The line ending sequence. Defaults to "\r\n". + + + + + + + + + &reftitle.returnvalues; + + Returns the chunked string. + + + + + &reftitle.examples; + <function>chunk_split</function> example @@ -32,13 +76,21 @@ $new_string = chunk_split(base64_encode($data)); - - See also str_split, - explode, split, - wordwrap and - RFC 2045. - + + + &reftitle.seealso; + + + str_split + explode + split + wordwrap + RFC 2045 + + + + - + convert_cyr_string Convert from one Cyrillic character set to another - - Description + + + &reftitle.description; stringconvert_cyr_string stringstr @@ -15,11 +15,42 @@ stringto - This function returns the given string converted from one - Cyrillic character set to another. The from - and to arguments are single characters that - represent the source and target Cyrillic character sets. The - supported types are: + Converts from one Cyrillic character set to another. + + + + + &reftitle.parameters; + + + + str + + + The string to be converted. + + + + + from + + + The source Cyrillic character set, as a single character. + + + + + to + + + The target Cyrillic character set, as a single character. + + + + + + + Supported characters are: @@ -53,9 +84,20 @@ + + + &reftitle.returnvalues; + + Returns the converted string. + + + + + &reftitle.notes; ¬e.bin-safe; + + convert_uudecode Decode a uuencoded string - - Description + + + &reftitle.description; stringconvert_uudecode stringdata @@ -14,6 +15,33 @@ convert_uudecode decodes a uuencoded string. + + + + &reftitle.parameters; + + + + data + + + The uuencoded data. + + + + + + + + + &reftitle.returnvalues; + + Returns the decoded data as a string. + + + + + &reftitle.examples; <function>convert_uudecode</function> example @@ -27,10 +55,17 @@ echo convert_uudecode("+22!L;W9E(%!(4\"$`\n`"); + + + + &reftitle.seealso; - See also convert_uuencode. + + convert_uuencode + + + convert_uuencode Uuencode a string - - Description + + + &reftitle.description; stringconvert_uuencode stringdata @@ -20,6 +21,33 @@ characters, making them safe for network transmissions. Uuencoded data is about 35% larger than the original. + + + + &reftitle.parameters; + + + + data + + + The data to be encoded. + + + + + + + + + &reftitle.returnvalues; + + Returns the uuencoded data. + + + + + &reftitle.examples; <function>convert_uuencode</function> example @@ -34,11 +62,18 @@ echo convert_uuencode($some_string); + + + + &reftitle.seealso; - See also convert_uudecode and - base64_encode. + + convert_uudecode + base64_encode + + - + count_chars Return information about characters used in a string - - Description + + + &reftitle.description; mixedcount_chars stringstring @@ -16,8 +16,37 @@ Counts the number of occurrences of every byte-value (0..255) in string and returns it in various ways. - The optional parameter mode defaults to - 0. Depending on mode + + + + + &reftitle.parameters; + + + + string + + + The examined string. + + + + + mode + + + The optional parameter mode defaults to 0. + + + + + + + + + &reftitle.returnvalues; + + Depending on mode count_chars returns one of the following: @@ -50,6 +79,10 @@ + + + + &reftitle.examples; <function>count_chars</function> example @@ -82,11 +115,18 @@ There were 1 instance(s) of "w" in the string. - - See also strpos and - substr_count. - + + + &reftitle.seealso; + + + strpos + substr_count + + + + - + crc32 Calculates the crc32 polynomial of a string - - Description + + + &reftitle.description; intcrc32 stringstr @@ -23,11 +23,40 @@ sprintf or printf to get the string representation of the unsigned crc32 checksum. + + + + &reftitle.parameters; + + + + str + + + The data. + + + + + + + + + &reftitle.returnvalues; + + + + + + + &reftitle.examples; - This second example shows how to print a converted checksum with the - printf function: Displaying a crc32 checksum + + This example shows how to print a converted checksum with the + printf function: + + + + + &reftitle.seealso; - See also md5 and sha1. + + md5 + sha1 + + - + crypt One-way string encryption (hashing) - - Description + + + &reftitle.description; stringcrypt stringstr @@ -16,16 +16,9 @@ crypt will return an encrypted string using the standard Unix DES-based encryption algorithm or - alternative algorithms that may be available on the system. Arguments - are a string to be encrypted and an optional salt string to base the - encryption on. See the Unix man page for your crypt function for more - information. + alternative algorithms that may be available on the system. - - If the salt argument is not provided, one will be randomly - generated by PHP each time you call this function. - - + Some operating systems support more than one type of encryption. In fact, sometimes the standard DES-based encryption is replaced by an MD5-based encryption algorithm. The encryption type is triggered by the @@ -34,16 +27,11 @@ salt is provided, PHP will auto-generate a standard two character salt by default, unless the default encryption type on the system is MD5, in which case a random MD5-compatible salt is generated. PHP sets a - constant named CRYPT_SALT_LENGTH which tells you whether a regular two - character salt applies to your system or the longer twelve character salt - is applicable. - - - If you are using the supplied salt, you should be aware that the salt is - generated once. If you are calling this function repeatedly, this may - impact both appearance and security. - - + constant named CRYPT_SALT_LENGTH which tells you + whether a regular two character salt applies to your system or the longer + twelve character salt is applicable. + + The standard DES-based encryption crypt returns the salt as the first two characters of the output. It also only uses the first eight characters of str, so longer strings @@ -58,36 +46,72 @@ - CRYPT_STD_DES - Standard DES-based encryption with a two character salt + CRYPT_STD_DES - Standard DES-based encryption with a two character salt - CRYPT_EXT_DES - Extended DES-based encryption with a nine character salt + CRYPT_EXT_DES - Extended DES-based encryption with a nine character salt - CRYPT_MD5 - MD5 encryption with a twelve character salt starting with + CRYPT_MD5 - MD5 encryption with a twelve character salt starting with $1$ - CRYPT_BLOWFISH - Blowfish encryption with a sixteen character salt + CRYPT_BLOWFISH - Blowfish encryption with a sixteen character salt starting with $2$ or $2a$ - - - There is no decrypt function, since crypt - uses a one-way algorithm. - - - - <function>crypt</function> examples - + + + + &reftitle.parameters; + + + + str + + + The string to be encrypted. + + + + + salt + + + An optional salt string to base the encryption on. If not provided, + one will be randomly generated by PHP each time you call this function. + + + If you are using the supplied salt, you should be aware that the salt + is generated once. If you are calling this function repeatedly, this + may impact both appearance and security. + + + + + + + + + &reftitle.returnvalues; + + Returns the encrypted string. + + + + + &reftitle.examples; + + + <function>crypt</function> examples + ]]> - - - - Using <function>crypt</function> with htpasswd - + + + + Using <function>crypt</function> with htpasswd + ]]> - - - - Using <function>crypt</function> with different encryption types - + + + + Using <function>crypt</function> with different encryption types + ]]> - - &example.outputs.similar; - + + &example.outputs.similar; + - - - - See also md5 and the - Mcrypt extension. - + + + + + + &reftitle.notes; + + + There is no decrypt function, since crypt uses a + one-way algorithm. + + + + + + &reftitle.seealso; + + + md5 + The Mcrypt extension + The Unix man page for your crypt function for more information + + + +