R
R
ruboss2015-10-08 13:52:19
PHP
ruboss, 2015-10-08 13:52:19

script tag inside block?

Hello everyone, I have a question.
I have a string in a div tag and it contains a script tag (as plain text). But the browser recognizes it as a tag and puts everything after it inside the tag. Tell me how to fix this)
You can use php and js, but I would like to find a solution without them)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cat Anton, 2015-10-08
@ruboss

Escape HTML special characters:
php.net/manual/ru/function.htmlspecialchars.php

echo htmlspecialchars('<script>...</script>', ENT_QUOTES); 
// &lt;script&gt;...&lt;/script&gt;

O
Orzubek Rakhimov, 2015-10-08
@orzubek


$text = $_POST["comment"];
echo htmlspecialchars($text);//can also return htmlspecialchars($text);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question