Home  >  Article  >  Backend Development  >  判断指 指定值输出!该如何解决

判断指 指定值输出!该如何解决

WBOY
WBOYOriginal
2016-06-13 12:04:48799browse

判断指 指定值输出!

<?php<br />$n=$_GET['che'];<br />define("A", $n);<br />if(A==star){echo '1';}<br />else if(A==movie){echo '9';}<br />else if(A==tv){echo '10';}<br />else if(A==yue){echo '10';}<br />else if(A==zongyi){echo '12';}<br />else if(A==news){echo '15';}<br />else if(A==yanchu){echo '13';}<br />else if(A==fashion){echo '20';}<br />else if(A==astro){echo '23';}<br /><br />在这里弄个  统一的值输出<br />$b  这样 echo 里的值全弄到$b去  用B输出<br />?>



------解决方案--------------------
$dict = array(<br />  'star' => '1',<br />  'movie' => '9',<br />  'tv' => '10',<br />  'yue' => '10',<br />  'zongyi' => '12',<br />  'news' => '15',<br />  'yanchu' => '13',<br />  'fashion' => '20',<br />  'astro' => '23',<br />);<br />echo isset($dict[$_GET['che']]) ? $dict[$_GET['che']] : ''

------解决方案--------------------
顶楼上版主  一看程序就知道经验不少!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn