store data into a text file using php?

前端 未结 6 1269
有刺的猬
有刺的猬 2021-01-13 14:46

i am trying to store data in a text file, something like an array into a text file using php instead of storing into mysql database.

for example here are the data to

6条回答
  •  悲&欢浪女
    2021-01-13 15:27

    You should make a uniqid then they won't be able to access any other txt files in the server.

     $username, "points" => 0];
    
        // Store the data
        file_put_contents($filename, serialize($userInfo));
    
        // How to get the data
        $userInfo = unserialize(file_get_contents($filename));
        print($userInfo["points"]);
        //or
        print($userInfo["username"]);
    
    ?>
    

提交回复
热议问题