开发者

PHP cannot print my string properly

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?


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


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.


It's because it print

#(<script.*?>).*?(</script>)

It's invisible to the browser but look in the source code, it should be there :D

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜