第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法在php中讀/寫文件

無法在php中讀/寫文件

PHP
明月笑刀無情 2021-07-06 13:56:58
我已經(jīng)閱讀了所有我能在 stackoverflow 上找到的關(guān)于這個問題的信息!這可能是重復(fù)的,但我無法解決我的問題: 我無法使用 php 處理文件。我已經(jīng)使用這些命令獲得許可:sudo chown -R www-data:www-data /var/www/mysite sudo chmod -R 777 /var/www/mysite這是代碼:<?phpif(isset( $_POST['save_values'])) { // retrieve the form data by using the element's name attributes value as key     if(!empty($_POST['getURL'])) {        $URL = $_POST['getURL'];    }    if(!empty($_POST['getRefreshRate'])) {        $RefreshRate = $_POST['getRefreshRate'];    }    if(!empty($_POST['getBrightness'])) {        $Brightness = $_POST['getBrightness'];    }}$filename = "/currentSettings.txt";chmod($filename,0777);$cSettings = fopen($filename, "r");if($cSettings) {    echo "$cSettings exists";    while(($line = fgets($cSettings)) !== false) {         $arr = explode("\n", $line);         $URL = $arr[0];         $RefreshRate = $arr[1];         $Brightness = $arr[2];    }    fclose($cSettings);} else {    echo "File does not exist";    fclose($cSettings);    $cSettings = fopen('/currentSettings.txt', 'w');    fwrite($cSettings,$URL."\n");    fwrite($cSettings,$RefreshRate."\n");    fwrite($cSettings,$Brightness."\n");    fclose($cSettings);}?>它總是返回File does not exist。它不會寫入文件,也不會從文件中讀取。我什至在 www/mysite 中手動創(chuàng)建了該文件,但它仍然無法讀取。我對 PHP 很陌生,我確信我的代碼壞了,但我找不到修復(fù)它的方法。
查看完整描述

1 回答

?
阿波羅的戰(zhàn)車

TA貢獻1862條經(jīng)驗 獲得超6個贊

我已經(jīng)閱讀了所有我能在 stackoverflow 上找到的關(guān)于這個問題的信息!這可能是重復(fù)的,但我無法解決我的問題: 我無法使用 php 處理文件。


我已經(jīng)使用這些命令獲得許可:


sudo chown -R www-data:www-data /var/www/mysite 

sudo chmod -R 777 /var/www/mysite

這是代碼:


<?php


if(isset( $_POST['save_values'])) { // retrieve the form data by using the element's name attributes value as key 

    if(!empty($_POST['getURL'])) {

        $URL = $_POST['getURL'];

    }


    if(!empty($_POST['getRefreshRate'])) {

        $RefreshRate = $_POST['getRefreshRate'];

    }


    if(!empty($_POST['getBrightness'])) {

        $Brightness = $_POST['getBrightness'];

    }


}


$filename = "/currentSettings.txt";

chmod($filename,0777);

$cSettings = fopen($filename, "r");


if($cSettings) {

    echo "$cSettings exists";

    while(($line = fgets($cSettings)) !== false) {

         $arr = explode("\n", $line);

         $URL = $arr[0];

         $RefreshRate = $arr[1];

         $Brightness = $arr[2];

    }

    fclose($cSettings);

} else {

    echo "File does not exist";

    fclose($cSettings);

    $cSettings = fopen('/currentSettings.txt', 'w');

    fwrite($cSettings,$URL."\n");

    fwrite($cSettings,$RefreshRate."\n");

    fwrite($cSettings,$Brightness."\n");

    fclose($cSettings);

}


?>

它總是返回File does not exist。它不會寫入文件,也不會從文件中讀取。我什至在 www/mysite 中手動創(chuàng)建了該文件,但它仍然無法讀取。


我對 PHP 很陌生,我確信我的代碼壞了,但我找不到修復(fù)它的方法。


查看完整回答
反對 回復(fù) 2021-07-16
  • 1 回答
  • 0 關(guān)注
  • 160 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號