PHP输出文件头错误
本地 nginx 1.09 测试一切正常,上传到服务器 nginx 1.12, 在选择文本输出时就报错
完整代码:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
@$id=$_GET['id']?$_GET['id']:'a';
@$txt=$_GET['txt']?$_GET['txt']:'';
$trees=array();
$trees["a"]="苹果";
$trees["b"]="香蕉";
$trees[3]="樱桃";
if($txt){
header('Content-Disposition: attachment; filename="'.$trees[$id].'.txt"');
header('Content-type: text/'.($txt?'plain':'html').'; charset=utf-8');
echo '您选择种了:'.$trees[$id].'树';
die();
}else{
echo '<h3>您选择种了:'.$trees[$id].'树</h3>';
?>
<form action="" method="get">
选择您想种的树:
<select name="id">
<?php foreach($trees as $key=>$tree){ echo '<option value="'.$key.'">'.$tree.'</option>'; } ?>
</select>树<br>
输出格式:<select name="txt">
<option value="">默认</option>
<option value="1">文本</option>
</select>
<input type="submit" value="提交">
</form>
<?php
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号