我正在编写如下所示的 php 代码,其中 Line#A 打印以下数组(如下所示 php 代码)。我的代码似乎没有进入 switch 语句。我不确定为什么。
我print_r($parts)
在 A 行添加以打印 $parts 的值。
php代码:
<?php
if (!empty($_POST['id']))
{
for($i=0; $i <count($mp4_files); $i++) {
if($i == $_POST['id']) {
$f = $mp4_files[$i];
$parts = pathinfo($f);
print_r($parts); // Line A
switch ($parts['extension'])
{
echo "Hello World"; // Line B
case 'mp4' :
$filePath = $src_dir . DS . $f;
system('ffmpeg -i ' . $filePath . ' -map 0:2 -ac 1 ' . $destination_dir . DS . $parts['filename'] . '.mp3', $result);
}
}
}
}
?>
输出(线#A):
Array
(
[dirname] => .
[basename] => hello.mp4
[extension] => mp4
[filename] => hello
)
我echo "Hello World"
在 B 线使用过,但由于某些原因,它没有被打印并扔到500 internal server error
控制台上。
问题陈述:
我想知道我应该在 php 代码中进行哪些更改,以便它进入 switch 语句。