目录结构如下
--includes/connection.php
--includes/functions.php
index.php
索引文件中的代码是
require('includes/connection.php');
require('includes/functions.php');
在functions.php中,我需要一次connection.php,函数文件中的函数是
function getUserInfos($someId) {
global $link;
$getUserInfos = mysqli_query($link, "SELECT * FROM users WHERE userId = {$someId}");
$getUserInfos = $getUserInfos->fetch_assoc();
return $getUserInfos['userId'];
}
在索引文件中,我想回显用户的ID,但是在此我得到一个空白响应
<?php echo getUserInfos($someId); ?>