热搜:NVER node 开发 php

php将数组或字符串写入文件

2024-08-19 22:50:01
php将数组或字符串写入文件

//将数组保存在文件中function export_to_file($file, $variable) {    $fopen = fopen($file, 'wb');    if (!$fopen) {        return false;    }    fwrite($fopen, "<?php \nreturn ".var_export($variable, true).";");    fclose($fopen);    return true;}//将字符串写入文件function put_to_file($file, $content) {    $fopen = fopen($file, 'wb');    if (!$fopen) {        return false;    }    fwrite($fopen, $content);    fclose($fopen);    return true;}