PHP curly braces in database

so i have a problem. We have several values ​​in our database, which are stored as follows:

{yoyoyo}

      

This is great until we pull the value out of the database using PHP. It seems to crash PHP when trying to access a variable like this:

$result['curly'];

      

For some reason PHP interprets this as its variable.

Does anyone know how to escape the result from the DB, so PHP interprets it as a string and not a variable?

Thank!

+3


source to share


2 answers


Yes, after further research it turned out that pulling the string value out of the database is just fine. However, later in our code we did other, let's just say, inefficient things. :)



+1


source


You can use htmlentities - http://php.net/manual/en/function.htmlentities.php

This will convert all characters to html objects. You can also store things in the future that shouldn't be used as variables for html objects before putting them into the database to avoid this problem.



http://www.freeformatter.com/html-entities.html

+2


source







All Articles