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. Thinkpad X240在Centos 7下使用ID 138a:0017或者vfs5011指纹识别

    我的笔记本是ThinknPad X240,自带的指纹识别器,通过命令lsusb可以查看: [zz@zz ~]$ lsusb Bus 001 Device 002: ID 24ae:2003 Bus 0 ...

  2. oracle decode

    decode()函数简介: 主要作用:将查询结果翻译成其他值(即以其他形式表现出来,以下举例说明): 使用方法: Select decode(columnname,值1,翻译值1,值2,翻译值2,.. ...

  3. ubuntu入门知识

    1.linux系统发展历史 unix -> Linux -> ubuntu linux发展轨迹图 2.ubuntu下载和安装 推荐使用长期支持版本: 10.04,12.04,14.04或L ...

  4. 你可能不知道的 30 个 Python 语言的特点技巧

        列表按难度排序,常用的语言特征和技巧放在前面. 1.1   分拆 >>> a, b, c = 1, 2, 3>>> a, b, c(1, 2, 3)> ...

  5. [DataTable]C# datatable取最大值最小值

    ArrayList al = new ArrayList(); DataTable dt = new DataTable(); dt.Columns.Add("A",typeof( ...

  6. oracle 表空间管理

    1.创建表空间 03:01:55 sys@ORADB11G> create tablespace TSPITR datafile '/u01/app/oracle/oradata/TSPITR0 ...

  7. 浅析人脸检测之Haar分类器方法

    一.Haar分类器的前世今生 人脸检测属于计算机视觉的范畴,早期人们的主要研究方向是人脸识别,即根据人脸来识别人物的身份,后来在复杂背景下的人脸检测需求越来越大,人脸检测也逐渐作为一个单独的研究方向发 ...

  8. [译] Closures in Lua - Lua中的闭包

    原文:(PDF) . 摘要 一等(first-class)函数是一种非常强大的语言结构,并且是函数式语言的基础特性.少数过程式语言由于其基于栈的实现,也支持一等函数.本文讨论了Lua 5.x用于实现一 ...

  9. USACO Section 3.3 骑马修栅栏 Riding the Fences

    题目背景 Farmer John每年有很多栅栏要修理.他总是骑着马穿过每一个栅栏并修复它破损的地方. 题目描述 John是一个与其他农民一样懒的人.他讨厌骑马,因此从来不两次经过一个栅栏.你必须编一个 ...

  10. 洛谷P2320 鬼谷子的钱袋

    P2320 06湖南 鬼谷子的钱袋 171通过 480提交 题目提供者xmyzwls 标签各省省选 难度普及+/提高 提交该题 讨论 题解 记录 最新讨论 题目有误 数据需要特判 评测系统太神了 题目 ...