gpt4 book ai didi

php - 简单代码 - 不输出消息

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:37:42 27 4
gpt4 key购买 nike

我正在使用 Hack,可以在 hacklang.org 找到它.

为什么下面的代码没有:

<?hh
$message = "Hey, lol.";
?>
<!doctype html>
<html lang="en-us">
<head>
<title>title</title>
</head>
<body>
<?= $message ?>
</body>
</html>

输出下面的文字?

嘿,哈哈。


error.log 文件中没有错误。当我“查看源代码”时,它是空白的,就像页面本身一样。


编辑:

伙计们,请看下面的代码来回复你的答案。如果您访问 hacklang.org(请参阅此问题中的 hack 标签 :) 并查看主页上的教程部分,请单击练习 3 of.. 它清楚地表明您应该使用 hh 而不是 php 来定义 hack 文档:

<?hh

// Hack functions are annotated with types.
function my_negation(bool $x): bool {
return !$x;
}

最佳答案

这应该有效:

<?php
$message = "Hey, lol.";
?>
<!doctype html>
<html lang="en-us">
<head>
<title>title</title>
</head>
<body>
<? echo $message; ?>
</body>
</html>

编辑:Hack 不能像上面那样与 html 混合使用。试试这个:

<?hh
$message = "Hey, lol.";
echo '
<!doctype html>
<html lang="en-us">
<head>
<title>title</title>
</head>
<body>
' . $message . '
</body>
</html>
';

关于php - 简单代码 - 不输出消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24791498/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com