Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在带有echo的PHP中使用html输出_Php_Html - Fatal编程技术网

无法在带有echo的PHP中使用html输出

无法在带有echo的PHP中使用html输出,php,html,Php,Html,我正在寻找html在php中的用法,我看到了一种可以这样使用的方法:echo' 我所做的是: $redirect = 'Redirecting to login page in 5 seconds. If it does not work, <a href="localhost:51631/login.aspx">click here</a> to do it manually.'; echo 'Account could not be verified. ' . $re

我正在寻找html在php中的用法,我看到了一种可以这样使用的方法:
echo'

我所做的是:

$redirect = 'Redirecting to login page in 5 seconds. If it does not work, <a href="localhost:51631/login.aspx">click here</a> to do it manually.';
echo 'Account could not be verified. ' . $redirect;

在我了解了json头之后,我将其命名为JSONHeader,并从原始的.php文件中删除了该头,因为该头还自动包含在中断html输出的文件中的“require_once”注释中。感谢@Progman向我显示错误。

尝试这样做,
而不是在锚标记中传递localhost,并将login.aspx文件放在该PHP代码文件所在的同一目录中。祝你好运

如果您发送的是JSON内容类型头,那么解决方案就是将内容类型头设置为text/html

这里有一个解决方案:

<?php 

require_once 'include/DB_Functions.php';

$db = new DB_Functions();
$token = $_GET["key"];

header('Content-Type: text/html; charset=utf-8');    

$redirect = 'Redirecting to login page in 5 seconds. If it does not work, <a href="localhost:51631/login.aspx">click here</a> to do it manually.';


if(isset($_GET["key"]) && $token !== "")
{
    $unique_id = $db->getUniqueIdFromToken($token);
    if(is_null($unique_id))
        echo 'Key not found.' . $redirect;
    else
    {
        $verify = $db->verifyAccount($unique_id);
        if($verify)
            echo 'Account is successfully verified. ' . $redirect;
        else
            echo 'Account could not be verified. ' . $redirect;
    }
}
else
    echo 'Key is missing.' . $redirect;
?>


你的问题是什么?只是尝试了一下,也没用。我的问题是如何在php代码中使用html标记,例如或。问题中解释了我尝试过的方法。什么不起作用??你想自动重定向吗?“我的问题是关于使用html标记,比如“-嗯?你的问题没有那种性质。对不起,我看不懂你的心思。为了避免程序员命名头文件并将其从另一个文件中删除,这个解决方案似乎更简单。因为它起作用了,我把这个标记为可接受的答案。
array (size=2)
  0 => string 'X-Powered-By: PHP/5.5.12' (length=24)
  1 => string 'Content-type:application/json;charset=utf-8' (length=43)
string 'BREAK' (length=5)
array (size=1)
  'X-Powered-By' => string 'PHP/5.5.12' (length=10)
<?php 

require_once 'include/DB_Functions.php';

$db = new DB_Functions();
$token = $_GET["key"];

header('Content-Type: text/html; charset=utf-8');    

$redirect = 'Redirecting to login page in 5 seconds. If it does not work, <a href="localhost:51631/login.aspx">click here</a> to do it manually.';


if(isset($_GET["key"]) && $token !== "")
{
    $unique_id = $db->getUniqueIdFromToken($token);
    if(is_null($unique_id))
        echo 'Key not found.' . $redirect;
    else
    {
        $verify = $db->verifyAccount($unique_id);
        if($verify)
            echo 'Account is successfully verified. ' . $redirect;
        else
            echo 'Account could not be verified. ' . $redirect;
    }
}
else
    echo 'Key is missing.' . $redirect;
?>