1

I am trying ot learn how to escape simple characters. I print the ASCII of the character >. But when I print it after using the function addcslashes..nothing is escaped. Why is that?

     $da=ord('>'); 
     echo $da."<br/>";
     $not_escaped="><?";
      $escaped = addcslashes($not_escaped, "\61...\64");
      echo  $escaped;

I followed their documentations..but my example above doesnt work. Thye also use 2 seperators !@ between the range of ASCII number range..what does it mean?

$escaped = addcslashes($not_escaped, "\0..\37!@\177..\377");
BlackFire27
  • 1,470
  • 5
  • 21
  • 32

1 Answers1

1

The ASCII codes in the $charlist are octal, not decimal. So to escape ">" (decimal: 62, octal: 76), use this code:

$escaped = addcslashes($not_escaped, "\76");

For a range, use two dots and not three ('a..z', not 'a...z').

pencil
  • 1,165
  • 8
  • 20