Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Monday, September 19, 2011

Convert String to Hexadecimal in PHP

bin2hex($string) will solve this problem. Don't get confused by the word bin in the function.

When I searched for converting a string to hexadecimal, in most of the blogs/Forums i got the following function.

function strToHex($string)
{
    $hex='';
    for ($i=0; $i < strlen($string); $i++)
    {
        $hex .= dechex(ord($string[$i]));
    }
    return $hex;
}

But when i tried to compare the output of above function with bin2hex (inbuilt PHP function), both got the same result.

Conclusion is if you want to convert a string into an hexadecimal string, then it's better to use bin2hex insted of the above function.

I tested it with the following example
"sfkjsd38jsdkjfD83kkksJADHAJ#$#JDKEHdjh843j4hjkDS&@)HDHSJKDHADASDSWE(Y#JDHSA*&#JKD3423523Sd"

Thursday, October 28, 2010

1030 - Got error 28 from storage engine - MySQL error

Hi back after long time. Want to keep in touch regularly from today onwards.

Today I got this error when i imported a new code into my M/C.
after importing the code i am unable to do any operations. For every operation on mysql it is throwing this error.
So i am unable to access my local sites too as the mysql is not working.

The cause for this error is the disk space. I had deleted the newly imported code from the system, then this issue got resolved. Means we need to delete unwanted files or we need to add extra space.

Thursday, November 19, 2009

Some of the PHP interview Quesitons

Some usefule links are ..



PHP Interview Questions – Web Applications
1)What is PHP?

2)What can PHP do?

3)Installing PHP on your Computer? What do you need?