Home > Backend Development > PHP Tutorial > 判断指 指定值输出!

判断指 指定值输出!

WBOY
Release: 2016-06-23 13:51:32
Original
849 people have browsed it

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



回复讨论(解决方案)

$n=$_GET['che'];define("A", $n);$b = '';if(A=='star'){$b = '1';}else if(A=='movie'){$b = '9';}else if(A=='tv'){$b = '10';}else if(A=='yue'){$b = '10';}else if(A=='zongyi'){$b = '12';}else if(A=='news'){$b = '15';}else if(A=='yanchu'){$b = '13';}else if(A=='fashion'){$b = '20';}else if(A=='astro'){$b = '23';}echo $b;
Copy after login

$dict = array(  'star' => '1',  'movie' => '9',  'tv' => '10',  'yue' => '10',  'zongyi' => '12',  'news' => '15',  'yanchu' => '13',  'fashion' => '20',  'astro' => '23',);echo isset($dict[$_GET['che']]) ? $dict[$_GET['che']] : ''
Copy after login
Copy after login

$dict = array(  'star' => '1',  'movie' => '9',  'tv' => '10',  'yue' => '10',  'zongyi' => '12',  'news' => '15',  'yanchu' => '13',  'fashion' => '20',  'astro' => '23',);echo isset($dict[$_GET['che']]) ? $dict[$_GET['che']] : ''
Copy after login
Copy after login





大哥
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template