character encoding - Has PHP's behaviour changed? -


studying zend-ce exam, came across question:

given php.ini setting of:
default_charset = utf-8
following code print in browser?

<?php    header('content-type: text/html; charset=iso-8859-1');    echo '&#9986;&#10004;&#10013;';    ?> 

a. garbled data
b. & # 9986 ; & # 10004 ; & # 10013 ;
c. blank line due charset mismatch

the expected answer c, expected - , when ran code, got garbled data (answer a)! wonder if phps behaviour had been changed or if error in test?

i not aware php behaviour has changed in respect. however, html standard has changed.

prior html 4, numeric character references such &#9986; interpreted respect document character set (which specified in content type header field). reasonable that, code point 9986 not exist in iso 8859-1, nothing printed.

since html 4, numeric character references interpreted unicode code points. echo '&#9986;&#10004;&#10013;'; should print ✂✔✝ regardless of content type header field says character set. reasonable call ✂✔✝ garbled data, if 1 not familiar unicode dingbats block.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -