Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text containing single quote as input value [PHP]

Tags:

php

I try to show this string : «let's go» in a the value of an input tag

i wrote: $chaine="let's go";

echo "<input type=text name=test value='".$chaine."'>";

result: let

What can i do to show the correct string in this case ?

like image 858
Amine Arous Avatar asked Dec 21 '22 18:12

Amine Arous


2 Answers

use htmlspecialchars

echo "<input type=text name=test value='".htmlspecialchars($chaine, ENT_QUOTES)."'>";
like image 189
bharath Avatar answered Dec 24 '22 08:12

bharath


You can look at htmlentities()

htmlentities($chaine, ENT_QUOTES) ;
like image 35
Shakti Singh Avatar answered Dec 24 '22 06:12

Shakti Singh