gpt4 book ai didi

PHP:字符串在外部文件中不起作用

转载 作者:行者123 更新时间:2023-11-30 00:51:11 28 4
gpt4 key购买 nike

我已经在外部文件中编写了一些字符串,因此我没有到处都有字符串,但它似乎不起作用。

Init.inc.php

$get_user = mysql_query("SELECT * FROM users WHERE username = '".$_SESSION['user']."'");
$user_data = mysql_fetch_array($get_user);
$userid = mysql_real_escape_string($user_data['id']);
$username = mysql_real_escape_string($user_data['username']);
$email = mysql_real_escape_string($user_data['email']);

Session.php

require("includes/config.php");
require("includes/init.inc.php");
echo "Hello", $username, $email;

它应该输出用户的用户名和电子邮件地址。预先感谢:)

最佳答案

如果您定义为 GLOBAL 则有效

require("includes/config.php");
require("includes/init.inc.php");
global $username, $email;
echo "Hello", $username, $email;

关于PHP:字符串在外部文件中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20956681/

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