有人可以建议一个较短的相同代码吗?
<?php
header("Content-type: application/doc");
basename($_GET["path"]));
$name = $_GET["name"];
header("Content-Disposition: attachment; filename='".$name.".doc");
header("Content-Transfer-Encoding: quoted_printable");
header('Pragma: no-cache');
header('Expires: 0');
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-Transfer-Encoding: binary');
header("Content-type: application/force-download");
header('Content-Type: application/octet-stream');
readfile($_GET["path"]);
答案 0 :(得分:1)
代替几个,或者您可以尝试在范围之间使用
CASE when substr({location}, -2) ='00'
or cast(substr({location}, -2)) AS UNSIGNED )between 10 and 13 then '1'
when cast(substr({location}, -2)) AS UNSIGNED) between 38 and 47 then '2'
else '3'
end
答案 1 :(得分:0)
如果使用的数据库支持正则表达式,则可以大大简化此过程。例如,在MySQL中:
(CASE WHEN {location} REGEXP '00$|010$|011$|012$|013$' THEN '1'
WHEN {location} REGEXP '38$|039$|040$|041$|042$|043$|044$|046$|047$' THEN '2'
ELSE '3'
END)