欢迎各位兄弟 发布技术文章
这里的技术是共享的
{{ strip_tags($yourString) }}
{!! !!}
I use CKEditor for adding content(instead of Textarea box).
When I display the content, it shows Tags, images,.. so I stripped by using
'e' method(and also using {{{ }}} )
However when I display the text, it shows
<p> Testing </p> <img src="/assets/img/1.jpg" >
How to safely sanitise the output to html ?
GiovanniK
Try it with two of the {{'s.
For example:
Sanitized: {{{ $var }}}
Not sanitzied: {{ $var }}
barryvdh
escaping is making sure the content doesn't get executed, so instead of an image, you see `<img ..> in plain text. That is safe. But if you want to remove all html, you can use http://php.net/strip_tags
sivaganeshsg
@barryvdh: thanks :)
piyushpune
hi
http://laravel.io/bin/32r7
I used such code to display content (using cketditor) But it display content with html tags. Can u help me.
I tried with {{{$page->description}}} but no help
todstoychev
Here I solved it with some help from uncle Google and some good guys like us that like to share their knowledge.
{{ preg_replace('/(<.*?>)|(&.*?;)/', '', $string) }}
the
(<.*?>)
seems to strip all the html tags pretty well.
(&.*?;)
strips all the HTML special characters, like:
© <, >
and other stuff
snky1987
Try
strip_tags($string)
It will give you just plain text form string. It helped of me.