The strip_tags()
function removes all html tags from the text. I basically do not mind using them on my forum, but I don’t want php code to be used in messages. Is it possible to get rid of the <? ?>
<? ?>
with content?
- Hmm, can you just put all the acceptable tags in the second argument of this function? .. - sinedsem
- 6do you have any eval messages on the form?) lol - Sh4dow
- Shh, I just learn the subtleties of creating a forum / dialogue .. Only to anyone, let it remain between us. =) I can't remove the tags that the WYSIWYG editor creates, right? - sinedsem
- So the correct editor will not allow them to be added, but will convert them to & lt / & gt - thunder
|
3 answers
echo preg_replace('#<\?(|php)([\s\S]*)\?>#i', '', file_get_contents('index.php'));
- What does: [\ s \ S] *? - ReinRaus
- @ReinRaus This code selects all characters, spaces, and line breaks. Read the documentation. Those. (. *) does not roll due to the fact that the sign "." does not capture line breaks. Such a thing is noticed by analyzing megaton regular smarty regulars, those are perverts. - lampa
- @lampa, so better: # <\? (?: php)?. *? \?> # is - ReinRaus
- @ReinRaus oh yes, I completely forgot about this modifier. But your method, of course, is not suitable for all cases of string translation. So in my defense I will say that I am engaged in js, and there is just the modifier "s" and no :-) - lampa
- oneNot immediately noticed: the order in alternatives is important. In this expression, it is not noticeable, but this is not what we would like to capture. preg_replace ("/ <\? (| php) /", "", "<? php some text"); At the output of
php some text
. The construction(expression|)
is used for guaranteed capture into the saving group, even if nothing matched, and (| expression) always coincides with nothing. - ReinRaus
|
What's the point?
PHP code and so will not run.
The content field that is sent to the server is a string. And this string is processed, so that it does not exist, just like a string.
|
I used my idea: I added all tags used by the editor to strip_tags (). Thank you for your responsiveness.
|