sprinit Weirdness
Well, I was coding a BBCode Parser (rather unconventional because the
parser will allow multiple attributes to a BBCode tag like [tag
attrib1="" attrib2=""]...[/tag])
Anyway, I was coding to allow escaped characters to appear inside the
attribute values and I came across this weird sprintf behaviour which I
wonder if it's a PHP bug.
code:
Expected Output:
Output:
It looks like sprintf doesn't like escaped quotes or something. If you
add any character after the missing quote, it will appear but the quote
will not.
I tested this on PHP 5.0.4 on Windows and Linux. Can anyone confirm this problem?
parser will allow multiple attributes to a BBCode tag like [tag
attrib1="" attrib2=""]...[/tag])
Anyway, I was coding to allow escaped characters to appear inside the
attribute values and I came across this weird sprintf behaviour which I
wonder if it's a PHP bug.
code:
PHP Code:
<?php
die(sprintf('<div%2$s>%1$s</div>',"ABC",' style=".\"." class="class"'));
?>
Expected Output:
Code:
<div style=".\"." class="class">ABC</div>
Output:
Code:
<div style=".\". class="class">ABC</div>
It looks like sprintf doesn't like escaped quotes or something. If you
add any character after the missing quote, it will appear but the quote
will not.
I tested this on PHP 5.0.4 on Windows and Linux. Can anyone confirm this problem?
