微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法写入文件 php

如何解决无法写入文件 php

我在用 PHP 将字符串写入文件时出错。代码如下。

$this->filecontent = '<?PHP
    require "../db_credintial.PHP";
    $currentdir = htmlspecialchars($_SERVER["PHP_SELF"]);
    $basename = basename($currentdir,".PHP");
    $updateauthsql = "UPDATE `member` SET `mailconfirmed` = '1' WHERE `member`.`identifier` = '".$basename."'"; // this is where error is generator when writing the whole string

    if($conn->query($updateauthsql))
    {
        echo "email is Now validated";
    }
    else{
        exit($conn->error) ;
    }
    
    ?>'; // this is the whole string



    $this->myfile = file_put_contents($this->filename,$this->filecontent); // create the new file

filecontent 变量有一个字符串值,但在字符串中,有一个包含其他变量的 sql 语句。将 PHP 编写为字符串时,此时我遇到错误。我假设问题出在引号上。有人可以帮忙吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。