With PHP echo I want to get this in the browser:
var x = "<td><a class=\"button3\"><input type=\"text\" name=\"" + a + "_" + y + "\" id=\"something\" value=\"\" class=\"inputText\"></a></td>";
How to escape this in PHP ?
With PHP echo I want to get this in the browser:
var x = "<td><a class=\"button3\"><input type=\"text\" name=\"" + a + "_" + y + "\" id=\"something\" value=\"\" class=\"inputText\"></a></td>";
How to escape this in PHP ?
You do not seem to be using single quotes '
so wrapping your line of code in a string is quite easy when using single quotes.
To literally show the text in your browser, you can use the htmlentities()
function and echo
it to output it to the browser:
echo htmlentities('var x = "<td><a class=\"button3\"><input type=\"text\" name=\"" + a + "_" + y + "\" id=\"something\" value=\"\" class=\"inputText\"></a></td>";');
It will convert all characters that are used in HTML to create tags. For example <
is converted to <
so it displays the correct character. Please take a look at the available flags and select the ones you require for properly displaying your line of code.