Web Hosting Talk







View Full Version : Help Needed in converting a .NET function to PHP


creativeartist
07-26-2007, 02:17 AM
hi,

I need this function converted to PHP

Function AscEncode(ByVal str)
Dim i
Dim sAscii
sAscii = ""
For i = 1 To Len(str)
sAscii = sAscii + CStr(Hex(Asc(Mid(str, i, 1))))
Next
AscEncode = sAscii
End Function

I am stuck with (Hex(Asc(Mid(str, i, 1)))) functions.I donot know how to convert a string to ASCII and HEX.I need a quick help

Burhan
07-26-2007, 02:48 AM
function AscEncode($str)
{
for($i = 0; $x < strlen($str); $i++)
{
$sAscii += dechex(asc($str[$i]));
}
return $sAscii;
}

creativeartist
07-26-2007, 02:55 AM
I have used it ,but it is showing an error

Fatal error: Call to undefined function asc()

foobic
07-26-2007, 03:31 AM
s/asc/ord/

creativeartist
07-26-2007, 04:18 AM
Sorry foobic, I didn't understand what you mean

foobic
07-26-2007, 04:33 AM
Replace asc with ord. ord() (http://au.php.net/manual/en/function.ord.php) is the perl / php function that returns the numeric ascii value of a character.

Azavia
07-26-2007, 09:51 AM
Just to clarify, that's not VB.NET; that's plain old VB. .NET is purely object oriented and there are no objects there.