嘿伙計(jì)們,這是我的代碼。 function markenbuero_csv() { // open the file "demosaved.csv" for writing $file = fopen('demosaved.csv', 'w'); // save the column headers fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5')); // Sample data. This can be fetched from mysql too $data = array( array('Data 11', 'Data 12', 'Data 13', 'Data 14', 'Data 15'), array('Data 21', 'Data 22', 'Data 23', 'Data 24', 'Data 25'), array('Data 31', 'Data 32', 'Data 33', 'Data 34', 'Data 35'), array('Data 41', 'Data 42', 'Data 43', 'Data 44', 'Data 45'), array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55') ); // save each row of the data foreach ($data as $row) { fputcsv($file, $row); } // Close the file fclose($file); echo 'worked'; }我通過我的 Wordpress 自定義插件頁面中的表單調(diào)用它,它呼應(yīng)了“工作”,但沒有在我的插件文件夾中創(chuàng)建文件。表單如下所示:<form style="margin-top:50px" action="#" method="post"> <input type="submit" name="a_submit" value="CSV laden"></form>和我稱之為的方式:if(isset($_POST['a_submit'])){ markenbuero_csv(); }我不確定我錯(cuò)過了什么。感謝您幫助我。
我在 php 中創(chuàng)建 csv 文件的功能通過但不創(chuàng)建文件
繁華開滿天機(jī)
2022-06-11 18:04:59