如何在函数内部调用函数?
这是我的function.php
function query_user() {
$q_user = pg_query("SELECT * FROM users WHERE username='".$_SESSION['username']."' AND password='".$_SESSION['password']."'");
$r_user = pg_fetch_array($q_user, NULL, PGSQL_ASSOC);
$user_tblrows = pg_num_rows($q_user);
if ($user_tblrows==1) {
$_SESSION['firstname'] = $r_user['firstname'];
$_SESSION['lastname'] = $r_user['lastname'];
function welcome_user() {
echo $_SESSION['lastname'].', '.$_SESSION['firstname'];
}
}
在我的单独文件中,我想调用函数 welcome_user()
我该怎么做?我很困惑。我这样做了,我知道这是不正确的。
require 'function.php';
welcome_user();