我有一個try catch
聲明與switch
聲明裏面。跳過父母功能,如果案件等於'合併'在PHP
我是一種新的PHP,所以請耐心等待。我知道這對PROS來說可能很簡單。
我想達成什麼是跳過頂部的第一個2條if
語句如果case is 'merge'
try {
if (!make_thumbnail($videoFile, $thumbLocal))
throw new \Exception ($thumbLocal);
if (!put_file($thumbLocal, $thumbRemote))
throw new \Exception($thumbRemote);
switch($message->priority) {
case 'mp4':
make_mp4($videoFile, $mp4file);
if (!file_exists($mp4file))
throw new \Exception($mp4file);
if (!put_file($mp4file, $remotemp4))
throw new \Exception($remotemp4);
send_ready_ping($message->ping, $message->id, VIDEO_MP4);
make_webm($videoFile,$webmfile);
if (!file_exists($webmfile))
throw new \Exception($webmfile);
if (!put_file($webmfile, $remotewebm))
throw new \Exception($remotewebm);
send_ready_ping($message->ping,$message->id,VIDEO_BOTH);
break;
case 'merge':
make_merged_video($videoFile, $audioFile, $mp4file, $message->options);
if (!file_exists($mp4file))
throw new \Exception($mp4file);
if (!put_file($mp4file, $remotemp4))
throw new \Exception($remotemp4);
send_ready_ping($message->ping, $message->id, VIDEO_MP4);
break;
default;
make_webm($videoFile,$webmfile);
if (!file_exists($webmfile))
throw new \Exception($webmfile);
if (!put_file($webmfile, $remotewebm))
throw new \Exception($remotewebm);
send_ready_ping($message->ping, $message->id, VIDEO_WEBM);
make_mp4($videoFile,$mp4file);
if (!file_exists($mp4file))
throw new \Exception($mp4file);
if (!put_file($mp4file, $remotemp4))
throw new \Exception($remotemp4);
send_ready_ping($message->ping,$message->id,VIDEO_BOTH);
break;
}
}
catch (\Exception $e) {
echo "Exception: " . $e->getMessage() . "\n";
send_ready_ping($message->ping, $message->id, VIDEO_FAIL);
}
我想跳過縮略圖生成每當case
等於「合併」
這些是我想跳過的代碼/事件:
if (!make_thumbnail($videoFile,$thumbLocal))
throw new \Exception ($thumbLocal);
if (!put_file($thumbLocal, $thumbRemote))
throw new \Exception($thumbRemote);
我試圖把它放在switch語句裏面,但是沒有工作:
if (case != "merge") {
if(!make_thumbnail($videoFile, $thumbLocal))
throw new \Exception ($thumbLocal);
if (!put_file($thumbLocal, $thumbRemote))
throw new \Exception($thumbRemote);
}
任何想法?
好的,謝謝。我忘了'$ message-> priority'是這裏的解決方案。我會試試這個 –