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模拟枚举的更多相关文章

  1. Codeforces 371A K-Periodic Array(模拟)

    题目链接 K-Periodic Array 简单题,直接模拟即可. #include <bits/stdc++.h> using namespace std; #define REP(i, ...

  2. Luogu P1039 侦探推理(模拟+枚举)

    P1039 侦探推理 题意 题目描述 明明同学最近迷上了侦探漫画<柯南>并沉醉于推理游戏之中,于是他召集了一群同学玩推理游戏.游戏的内容是这样的,明明的同学们先商量好由其中的一个人充当罪犯 ...

  3. Codeforces 439C Devu and Partitioning of the Array(模拟)

    题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...

  4. BZOJ 1088: [SCOI2005]扫雷Mine【思维题,神奇的模拟+枚举】

    1088: [SCOI2005]扫雷Mine Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3791  Solved: 2234[Submit][St ...

  5. UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. 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 ...

  7. CodeForces - 831A Unimodal Array 模拟

    A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  8. USACO 1.3.4 Prime Cryptarithm 牛式(模拟枚举)

    Description 下面是一个乘法竖式,如果用我们给定的那n个数字来取代*,可以使式子成立的话,我们就叫这个式子牛式. * * * x * * ------- * * * * * * ------ ...

  9. 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 ...

随机推荐

  1. English Notes

    1. Thanks for stopping by.慢走不送. 2. I don't like to judge a book by it's cover.我不喜欢以貌取人. 3. Rush hour ...

  2. 新找到的一款字体 fantasque-sans-mono

    http://www.ipreferjim.com/2015/03/your-ides-font-matters-fantasque-sans-mono/

  3. Perl模块的安装方法

    1. 下载离线安装包 *.tar.gz的形式解包后,#perl Makefile.PL#make#make install 2. 在联网的情况下,通过CPAN安装# perl -MCPAN -e sh ...

  4. shell如何传递外部参数给文件

    shell里面如何传递参数: sh test.sh zhang 20 那test.sh里面咋接受参数呢? #!/usr/bin/env sh name=$1 age=$2 echo "nam ...

  5. [Flex] ButtonBar系列——flex3 labelFunction用户提供的函数,在每个项目上运行以确定其标签

    <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="h ...

  6. C# UserControl 判断DesignMode

    C# UserControl 判断DesignMode   .Net开发UserControl时,我们经常需要得知当前是Design Mode还是Runtime Mode. 在Design Mode时 ...

  7. c/c++笔记

    string 若要根据字典序比较string类型的大小,只需要用><=就可以啦 例如: string s1="abcz"; string s2="abcd&q ...

  8. 剑指Offer:面试题14——调整数组顺序使奇数位于偶数前面(java实现)

    问题描述 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有奇数位于数组的前半部分,所有偶数位于数组的后半部分. 思路: 1.最简单的想法,不考虑时间复杂度,扫描数组,遇到偶数,先取出这 ...

  9. POJ1002_487-3279_C++

    题目:http://poj.org/problem?id=1002 我知道你们最需要的是这个 [ 手动滑稽 ] STD 给出的方法是丢进一个数组,然后排序,相邻的是重复的 这个方法,时间复杂度很不错, ...

  10. flex的Cairngorm框架

    由于要写flex的项目,接触了一段时间的Cairngorm框架,初步认识它是flex的一个mvc结构的框架实现了页面,调用相应方法的控制,和后台交互之间的三层之间的联系.Cairngorm框架主要包括 ...