I’m pulling data from my database that is as such (raw):
long's streetWe’d " tree < < ! cool & <body>
From everything I understand, for this to be output to a html page i should need to wrap it in htmlEntities.
But when I wrap it, it outputs nothing.
var_dump shows:
long's streetWe�d " tree < < ! cool & <body>
Wrapping in htmlspecialchars outputs:
long's streetWe’d " tree < < ! cool & <body>
var_dump output is the same for this one.
BUT outputting without using a wrapping function outputs it exactly as I want it to appear, as it is stored on the database.
When I output it it’s being displayed via a forms populate method (this value is in a larger array of data)
I have no clue why it does this. Does anyone have any idea?
This is all built in php using zend with a mysql db.
Kind Regards,
Presumably the forms populate method expects you to give it text and not HTML, so it converts to HTML before outputting the data.
This is a standard, and sensible approach to the problem. Data should be escaped at the last possible moment (to avoid it being escaped inappropriately).