artwilkes
asked on
PHP Character processing
This code always fails, return FALSE, even thought the first character is a B or 66.
I'm not sure how to format character processing in PHP.
My desire is the see if there are any characters below 64 that are not vaild in this buffer.
Seems like this should be simple, but it's not.
Thanks
for ( $i = 0 ; $i < 102 ; $i += 1){
if ($pszBuffer[$i] < 64){
return FALSE;
}
}
I'm not sure how to format character processing in PHP.
My desire is the see if there are any characters below 64 that are not vaild in this buffer.
Seems like this should be simple, but it's not.
Thanks
for ( $i = 0 ; $i < 102 ; $i += 1){
if ($pszBuffer[$i] < 64){
return FALSE;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This PHP page clearly shows (in color) what the difference between PHP's interpretation of '< 64' and '< "@" ' is.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PHP Buffer Check</title>
</head>
<body>
<h1>PHP Buffer Check</h1>
<?php
$pszBuffer = "This code always fails, return FALSE, even thought the first character is a B or 66. I'm not sure how to format character processing in PHP. My desire is the see if there are any characters below 64 that are not vaild in this buffer. Seems like this should be simple, but it's not.";
for ( $i = 0 ; $i < 102 ; $i++){
if ($pszBuffer[$i] < 64){
echo $i.":<span style='color: #ffffff;background-color: #ff0000;'>".$pszBuffer[$i]."</span> ";
}
}
echo "<br><br>";
for ( $i = 0 ; $i < 102 ; $i++){
if ($pszBuffer[$i] < '@'){
echo $i.":<span style='color: #ffffff;background-color: #ff0000;'>".$pszBuffer[$i]."</span> ";
}
}
?>
</body>
</html>
ASKER