Friday, January 26, 2007

php - chr function

chr

(PHP 3, PHP 4, PHP 5)
chr -- Return a specific character
Description
string chr ( int ascii )

Returns a one-character string containing the character specified by ascii.

Example 1:
<?php
$str .= chr(27); /* add an escape character at the end of $str */

/* Often this is more useful */

$str = sprintf("The string ends in escape: %c", 27);
?>

Thursday, January 25, 2007

php - chop function

chop

(PHP 3, PHP 4, PHP 5)
chop -- Alias of rtrim()
Description

This function is an alias of: rtrim().

Note: chop() is different than the Perl chop() function, which removes the last character in the string.

Example 1:
To get a perl style chop():
<?php
$foo = "bar";
$foo = substr("$foo", 0, -1);
echo $foo;

//returns "ba" (removes last character)
?>

Example 2:
<?php
$str = "i am best !\n\n";
echo $str; // displaying value before chop function
echo chop($str); // displaying value with chop
function
?>

Out Put Will Be :(HTML)
<html<
<body<
i am best !

i am best !</body<
</html<
In the above example chop function has removed "\n\n"

Page Out Put Will Be : i am best !i am best !

Wednesday, January 24, 2007

php - bin2hex function

bin2hex

(PHP 3 >= 3.0.9, PHP 4, PHP 5)
bin2hex -- Convert binary data into hexadecimal representation
Description
string bin2hex ( string str )

Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first.

php - addslashes function

addslashes

(PHP 3, PHP 4, PHP 5)
addslashes -- Quote string with slashes
Description
string addslashes ( string str )

Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).

An example use of addslashes() is when you're entering data into a database. For example, to insert the name O'reilly into a database, you will need to escape it. Most databases do this with a \ which would mean O\'reilly. This would only be to get the data into the database, the extra \ will not be inserted. Having the PHP directive magic_quotes_sybase set to on will mean ' is instead escaped with another '.

The PHP directive magic_quotes_gpc is on by default, and it essentially runs addslashes() on all GET, POST, and COOKIE data. Do not use addslashes() on strings that have already been escaped with magic_quotes_gpc as you'll then do double escaping. The function get_magic_quotes_gpc() may come in handy for checking this.

Example (1):
<?php
$str = "Is your name O'reilly?";

// Outputs: Is your name O\'reilly?
echo addslashes($str);
?>

php - addcslashes function

addcslashes

(PHP 4, PHP 5)
addcslashes -- Quote string with slashes in a C style
Description
string addcslashes ( string str, string charlist )

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.

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.

charlist like "\0..\37", which would escape all characters with ASCII code between 0 and 31.

Example (1):


<?php
echo addcslashes('foo[ ]', 'A..z');
// output: \f\o\o\[ \]
// All upper and lower-case letters will be escaped
// ... but so will the [\]^_` and any tabs, line
// feeds, carriage returns, etc.
?>


Welcome to Help

Welcome to PHP phpphpphp.blogspot.com : Your PHP Help Center!

This website exists to provide you with information to use while learning or developing PHP and MySQL. If you need PHP Help or you would like to provide PHP Help to other developers, you are in the right place. Additionally, we offer Apache Help, MySQL Help, Javascript Help, CSS Help, XML Help and much more.

This is a community website and we ask that you join to gain access to our interactive features and also assist others by sharing your knowledge about PHP and MySQL.