0
下面是在執行時拋出一些錯誤的代碼。我想要做的是無論發生什麼(錯誤或沒有錯誤),代碼的最後一行都會被執行。獲取執行的特定代碼行「No Matter What」
<?php
require 'main.php';
function create_photo($file_path) {
# Upload the received image file to Cloudinary
@$result = \Cloudinary\Uploader::upload($file_path, array(
"tags" => "backend_photo_album",
));
@unlink($file_path);
error_log("Upload result: " . \PhotoAlbum\ret_var_dump($result));
$photo = \PhotoAlbum\create_photo_model($result);
return $result;
}
$files = $_FILES["files"];
$files = is_array($files) ? $files : array($files);
$files_data = array();
foreach ($files["tmp_name"] as $index => $value) {
array_push($files_data, create_photo($value));
}
?>
<script>window.location.replace('index.html')</script>
任何幫助將不勝感激。由於
你應該閱讀錯誤處理.. [_try..catch..finally .._](https://athos.blogs.balabit.com/2011/02/try-catch-finally-in-php/ ) –
@PeeHaa,STFU運營商? Oo –
@ShankarDamodaran http://www.php.net/manual/en/language.operators.errorcontrol.php – PeeHaa