PHP用Array模拟枚举
C#中枚举Enum的写法:
/// <summary>
/// 公开类型 2-好友可见 1-公开 0-不公开
/// </summary>
public enum OpenStatusWithFriend
{
/// <summary>
/// 不公开
/// </summary>
Close = ,
/// <summary>
/// 公开
/// </summary>
Open = ,
/// <summary>
/// 好友可见
/// </summary>
Friend =
}
PHP中没有枚举类型,用Array来模拟表示:
public class testInfo
{
//公开类型
public static $OpenStatusWithFriend = array (
//不公开
'Close' => 0,
//公开
'Open' => 1,
//好友可见
'Friend'=>2
);
}
PHP访问:
$openType = testInfo::$OpenStatusWithFriend['Close'];
PHP用Array模拟枚举的更多相关文章
- Codeforces 371A K-Periodic Array(模拟)
题目链接 K-Periodic Array 简单题,直接模拟即可. #include <bits/stdc++.h> using namespace std; #define REP(i, ...
- Luogu P1039 侦探推理(模拟+枚举)
P1039 侦探推理 题意 题目描述 明明同学最近迷上了侦探漫画<柯南>并沉醉于推理游戏之中,于是他召集了一群同学玩推理游戏.游戏的内容是这样的,明明的同学们先商量好由其中的一个人充当罪犯 ...
- Codeforces 439C Devu and Partitioning of the Array(模拟)
题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...
- BZOJ 1088: [SCOI2005]扫雷Mine【思维题,神奇的模拟+枚举】
1088: [SCOI2005]扫雷Mine Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3791 Solved: 2234[Submit][St ...
- UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- codeforces 251 div2 C. Devu and Partitioning of the Array 模拟
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...
- CodeForces - 831A Unimodal Array 模拟
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- USACO 1.3.4 Prime Cryptarithm 牛式(模拟枚举)
Description 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. * * * x * * ------- * * * * * * ------ ...
- Codeforces Round #417 (Div. 2)A B C E 模拟 枚举 二分 阶梯博弈
A. Sagheer and Crossroads time limit per test 1 second memory limit per test 256 megabytes input sta ...
随机推荐
- CentOS7 安装Redis 3.2.3
$ wget http://download.redis.io/releases/redis-3.2.3.tar.gz $ tar xzf redis-3.2.3.tar.gz $ cd redis- ...
- inno setup 在卸载时如果想保留文件 使用uninsneveruninstall
一般来说,inno只卸载你安装的文件,自动生成如Thumb.db(缩略图)等文件,卸载程序是不会删除这些的,此时你希望整个安装目录删除则可用你说的方法删除.若想保留某些文件,则必须在[File]段中拷 ...
- esriSRProjCS2Type Constants
ArcGIS Developer Help (Geometry) esriSRProjCS2Type Constants See Also esriSRProjCSType Constants ...
- 菜鸟-手把手教你把Acegi应用到实际项目中(2)
上一篇是基于BasicProcessingFilter的基本认证,这篇我们改用AuthenticationProcessingFilter基于表单的认证方式. 1.authenticationProc ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem I
Problem I Interesting Calculator There is an interesting calculator. It has 3 rows of button. Row 1: ...
- 多媒体编程基础之RGB和YUV
一.概念 1.什么是RGB? 对一种颜色进行编码的方法统称为“颜色空间”或“色域”.用最简单的话说,世界上任何一种颜色的“颜色空间”都可定义成一个固定的数字或变量.RGB(红.绿.蓝)只是众多颜色空间 ...
- nginx如何限速?
nginx自从1.1.8版本发布后将limit_conn更换为limit_conn_zone . 对应则需要修改配置文件 在nginx.conf的http下面加入下面代码limit_conn_zone ...
- GUI创建各常用控件(二)
继续接着上一篇! 在我看来有一点需要申明:由于是GUI的相关知识,所以我只是在复习中粗略的总结而已,因此参考价值可能有限,更多的是当作自己学习的一个记录以及便于自己查阅. 好啦!干货继续: 1.类似于 ...
- IT综合学习网站收集
最近整理了一下曾经使用过的IT从入门到广泛的综合类基础学习网站,记录下来,以便初学者使用: 1.http://www.w3school.com.cn/ 中文版基础在线学习平台 2.http://ww ...
- Operator overloading
By defining other special methods, you can specify the behavior of operators on user-defined types. ...