私はscript.phpにこのコードを持っている:私は持っているインクルードされたスクリプトで定義された変数に値がないのはなぜですか?
<?php
session_start();
$user_session = $_SESSION['u_name'];
class check_sess {
public function check_id_session($user_session, $db) { //email
$stmt = $db->prepare('select id_user from users where email=?');
$stmt->bind_param('s', $user_session);
$stmt->execute();
$stmt->bind_result($id);
if ($stmt -> fetch()) {
$id;
echo $id; // here shows 20 for example
return true;
}
else
return false;
$stmt->close();
$db->close();
}
}
?>
とdemo.phpで:
include 'script.php';
$val = new check_sess();
$val-> check_id_session($user_session, $db);
echo $id; //problem here. It is supposed echo 20
は、なぜ私はecho $id
を行うことはできませんか? demo.phpには出力がありません。