Thursday, September 30, 2010

PHP ' become '

in PHP What happen when I output the string into text file is
The character ' become '

Copy this ' to create this '

' is a html character special code that represent ' symbol
Means it will display correctly as ' if you see it in web browser

Simply solving the problem by html_entity_decode( "'", ENT_QUOTES)

Note that html_entity_decode( "'") will not work
I found this solution in some page (didnt remember the site URL, sorry >.<)

So what is this html_entity_decode(...) function?
It is use to convert special html character into the normal character
Detail was in http://php.net/manual/en/function.html-entity-decode.php

The inverse of it was htmlentities(...)
Detail was in http://www.php.net/manual/en/function.htmlentities.php

No comments: