读书人

html内嵌php出现乱码最简单的php程序

发布时间: 2012-03-12 12:45:33 作者: rapoo

html内嵌php出现乱码,最简单的php程序也通不过

PHP code
<html><head>  <title>connect.php</title></head><body>    <strong>This is true.</strong><a href="<?php echo www.baidu.com; ?>">ÕâÊǸö³¬Á´½Ó</a><table>            <tr>                <td>rrrrrr</td>                <td>hhhhhh</td>            </tr></table><?php     $a=8;    $b=4;    if($a>$b){            $a++;        }        $c=$a+$b;        echo "a+b=".$c;?></body></html>

我这里要是单单
PHP code
<?php     $a=8;    $b=4;    if($a>$b){            $a++;        }        $c=$a+$b;        echo "a+b=".$c;?>

是能显示出来的
或者
PHP code
    <strong>This is true.</strong><a href="<?php echo www.baidu.com; ?>">超级连接</a>
也能显示出来,
但是下面放了
PHP code
<table>            <tr>                <td>rrrrrr</td>                <td>hhhhhh</td>            </tr></table>

就出现乱码了。。。为什么会这样?

[解决办法]
应该不可能。除非你输入时就已经乱码了。
[解决办法]
看看你的文件编码
[解决办法]
1.文件自身编码

2.html编码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

[解决办法]
PHP code
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  <title>connect.php</title></head><body>    <strong>This is true.</strong><a href="<?php echo www.baidu.com; ?>">超级链接</a><table>            <tr>                <td>rrrrrr</td>                <td>hhhhhh</td>            </tr></table><?php     $a=8;    $b=4;    if($a>$b){            $a++;        }        $c=$a+$b;        echo "a+b=".$c;?></body></html> 

读书人网 >PHP

热点推荐