Home > Backend Development > PHP Tutorial > array_key_exists()怎么配合switch()使用

array_key_exists()怎么配合switch()使用

WBOY
Release: 2016-06-13 11:45:00
Original
1275 people have browsed it

array_key_exists()如何配合switch()使用
各位看官,下的代码如何写才能正常运行

<br /><br />		switch (array_key_exists('dopost',$_GET())) <br />		{<br />			case 'dopost':<br />				# code...<br />				break;<br />			case 'edit':<br />				break;<br /><br />			//后面还有好几个<br />			<br />			default:<br />				# code...<br />				break;<br />		}<br /><br />
Copy after login

不要用IF 因为IF太多可读性差一点,速度上也会有点打折(只是听说,水平未到这个高度,无法用代码验证)

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