简体   繁体   English

HTML代码显示在.PHP页面中

[英]HTML code is showing in .PHP page

i'm writing my first page with PHP and HTML mixed. 我正在用PHP和HTML混合编写第一页。 This page shows the visitor's ip address (ipv4 or ipv6). 此页面显示访问者的IP地址(ipv4或ipv6)。 The PHP script is working fine, but the HTML code is showing as text instead of rendering. PHP脚本运行正常,但是HTML代码显示为文本而不是呈现。

<!doctype html>
<html>
<title>mioipv6.it</title>
<body>
<?php
header('Content-type: application/json');
if ( array_key_exists('addr', $_GET) )
$ip = $_GET['addr'];
else
$ip = $_SERVER['REMOTE_ADDR'];
$v6 = preg_match("/^[0-9a-f]{1,4}:([0-9a-f]{0,4}:){1,6}[0-9a-f]{1,4}$/", $ip);
$v4 = preg_match("/^([0-9]{1,3}\.){3}[0-9]{1,3}$/", $ip);
if ( $v6 != 0 )
$type = "IPv6";
elseif ( $v4 != 0 )
$type = "IPv4";
else
$type = "unknown";
echo json_encode(array("Il tuo indirizzo" => $ip, "Tipo" => $type));
?> 
<a href='http://ipv6-test.com/validate.php?url=referer'><img src='http://ipv6-test.com/button-ipv6-small.png' alt='ipv6 ready' title='ipv6 ready' border='0' /></a>
</body>
</html>

you can see the page here: www.mioipv6.it 您可以在此处查看页面:www.mioipv6.it

去掉

header('Content-type: application/json');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM