470,864 Members | 1,989 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,864 developers. It's quick & easy.

"\90" != chr(90)

Obviously, "\9" equals chr(9), but what would equal chr(90)? "\90"
doesn't. Rather, "\90" seems to be equal to chr(9).chr(0). So what
could I do to get chr(90) using escaped numbers?

Jan 4 '06 #1
2 2018
yawnmoth wrote:
Obviously, "\9" equals chr(9), but what would equal chr(90)? "\90"
doesn't. Rather, "\90" seems to be equal to chr(9).chr(0). So what
could I do to get chr(90) using escaped numbers?


You can't do it with numbers in base 10.
You can do it with numbers in base 8 or 16.

http://www.php.net/manual/en/language.types.string.php

$s_b16 = "\x5a";
$s_b8 = "\132";
$s_90 = chr(90);
/* all these strings are equal */

$s_x90 = "\90";
$s_d90 = chr(9*16+0); /* chr(144) */

Jan 4 '06 #2
On 4 Jan 2006 14:19:01 -0800, "yawnmoth" <te*******@yahoo.com> wrote:
Obviously, "\9" equals chr(9),
That's not obvious, in fact it shouldn't equal chr(9) unless I'm missing an
extra section in the string parsing rules. That's the literal string "\9"
(length 2, slash followed by nine).

andyh@server ~/public_html $ cat test.php
<?php
var_dump("\9");
?>
andyh@server ~/public_html $ php -q test.php
string(2) "\9"
but what would equal chr(90)? "\90"
doesn't. Rather, "\90" seems to be equal to chr(9).chr(0). So what
could I do to get chr(90) using escaped numbers?


\132

As with Perl, C and C++, you use octal in this type of escape sequence.

http://www.php.net/manual/en/language.types.string.php
(scroll down to table 11-1).

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jan 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dario de Judicibus | last post: by
11 posts views Thread by Dario (drinking coffee in the office…) | last post: by
5 posts views Thread by Dan C Douglas | last post: by
3 posts views Thread by Mark | last post: by
16 posts views Thread by Tantale | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.