gpt4 book ai didi

php - 当我在 php 上使用 '"时,解析错误 : syntax error, 意外 'class' '

转载 作者:行者123 更新时间:2023-12-03 02:58:32 25 4
gpt4 key购买 nike

class MailAuthGen{
var $mail='test@mail.com';
var $findUid = "SELECT uid from 'accounts' where email='$mail'";
function abc() {
echo $this->findUid;
}
}

当我加载此页面时,页面显示

Parse error: syntax error, unexpected '"'

均匀

$findUid = "SELECT uid from 'accounts' where email='".$mail."'";

没用。

但是,当我不使用“class”时,它执行得很好。

有什么问题吗?

最佳答案

错误出在这一行。声明属性时不能评估任何变量。

var $findUid = "SELECT uid from 'accounts' where email='$mail'";
// You can't do this ------^

常见的解决方法如下:

var $findUid = "SELECT uid from 'accounts' where email='%s'";

您可以稍后在其中插入值。

关于php - 当我在 php 上使用 '"时,解析错误 : syntax error, 意外 'class' ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11830420/

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