Reputation: 14844
so I have the following code:
$tag = 'script';
$r = '#(<'.$tag.'.*?>).*?(</'.$tag.'>)#';
echo $r;
but then when it echoes, it merely echoes this: #().*?()#
not even the 'script' is being echoed.....and notice that the less than equal sign, etc are not there...
what am I doing wrong?
Upvotes: 0
Views: 366
Reputation: 53607
do view source to see why. It will probbably be:
#(<script.*?>).*?(</script>)#';
Which each browser will display as
#().*?()#
As it hides any XML tags from the parsed view, i.e hides the <script.*?>
and the </script>
which can be seen, though, in the unparsed version->view source
Upvotes: 4
Reputation: 5119
It's because it print
#(<script.*?>).*?(</script>)
It's invisible to the browser but look in the source code, it should be there :D
Upvotes: 1
Reputation: 10518
If you're printing to HTML or a web browser, it will be ignoring tags it doesn't understand or wouldn't normally display, like <script>
. See this jsfiddle for example.
Upvotes: 2