开发者

CGI::escapeHTML() doesn't work

开发者 https://www.devze.com 2023-02-28 03:04 出处:网络
I am new to CGI, my code output: Hello, \"<h1>Tom Cat</h1>\"! Seems the escapeHTML() doesn\'t work.

I am new to CGI, my code output:

Hello, "<h1>Tom Cat</h1>"!

Seems the escapeHTML() doesn't work.

I develope my cgi code with XAMPP 1.7.2 on winxp. How can I fix it. Do I need download & install extra CGI Plugin for the current XAMPP? Appreciated for your help.

#!C:/Perl/bin/perl.exe -w


use strict; 
use CGI;

my $q = CGI->new();

print $q->he开发者_如何学Goader();
my $value = $q->param("myvar");

print $q->header();
print "<html><body>";
#print qq{Hello, "$value"!\n};
print qq{Hello, "}, CGI::escapeHTML($value), qq{"!\n};
print "</body></html>";


What are you expecting it to do? escapeHTML takes your string and changes it so the what will display is what is in the string - it turns it into something else that your browser then turns back to the original test.

It would appear that your parameter "myvar" contains the <h1> tags, which escapeHTML turns into &lt;h1&gt;, so that your browser can restore the original text.

If you want it not to do this but to interpret the tags, you need not to escape it.

0

精彩评论

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

关注公众号