CodeIgniter : form input set_value cause " to become & quot
Problem :
A string retrieved from database contains "
and when you try to display the string with Form Helper's set_value()
function. The "
becomes "
How to fix this problem?
Solution :
By default the set_value()
function will escape the value. (see http://www.codeigniter.com/userguide3/helpers/formhelper.html#setvalue) and this will cause "
to become "
Therefore, to fix this problem, turn off the HTML escaping by setting false
in the 3rd parameter of the set_value()
function.
From
set_value('sometitle', $sometitle);
to
set_value('sometitle', $sometitle, false);
This should prevent the "
to become "
now after disabling the default HTML escaping.
Reference :
http://www.codeigniter.com/userguide3/helpers/formhelper.html#setvalue
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+17.5k Golang : Clone with pointer and modify value
+9.1k Golang : Write multiple lines or divide string into multiple lines
+6.6k Golang : Derive cryptographic key from passwords with Argon2
+6.2k Javascript : Generate random key with specific length
+9.9k Golang : Check if user agent is a robot or crawler example
+11.7k Golang : Verify Linux user password again before executing a program example
+6.8k Android Studio : Hello World example
+9.7k PHP : Get coordinates latitude/longitude from string
+23k Golang : Randomly pick an item from a slice/array example
+9.4k Facebook : Getting the friends list with PHP return JSON format