php - 如何隐藏显示在 HTML 上的回显结果?

标签 php html

例如,考虑这个标准数据库连接 php 文件。

db_conn.php

<?php

$servername = "localhost";
$username = "root";
$password = "Yash123";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

如果连接成功,则会在网站上显示结果。

我需要它做的不是显示在 html 上,而是显示在文件中,这样我就可以测试在 PHP 的 CLI(命令行界面)中执行的文件。

我正在使用 require_once();在索引文件中。

最佳答案

取消注释 echo 行。或者使用php的error_log('连接成功');。这将记录连接成功。这将隐藏 html 中的输出,并将作为参数传递的字符串记录到 error_log 文件

关于php - 如何隐藏显示在 HTML 上的回显结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46010310/

相关文章:

php - Ajax 不发送数据 [Codeigniter]

PHP ucwords 函数问题

javascript - PHP 和 jquery 倒计时

移动 CKEditor 节点时 Javascript DOM 失败

html - CSS 未导入 HTML

javascript - React 应用程序和 Laravel API 的 CORS 问题

html - IE8 CSS 宽度,不能用百分比?

python - 列出时间格式的元素并计算与今天的时间差异

javascript - 存在溢出但滚动不适应它

php - 交响乐 4 : You have requested a non-existent service