当前位置: 首页>>代码示例>>PHP>>正文


PHP Color::YELLOW方法代码示例

本文整理汇总了PHP中Color::YELLOW方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::YELLOW方法的具体用法?PHP Color::YELLOW怎么用?PHP Color::YELLOW使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color::YELLOW方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 public static function main()
 {
     $color1 = Color::BLUE();
     $color2 = Color::YELLOW();
     $color3 = Color::BLUE();
     self::displayColor($color1);
     self::displayColor($color2);
     self::displayColor($color3);
     self::compareColor($color1, $color2);
     self::compareColor($color2, $color3);
     self::compareColor($color1, $color3);
     self::compareColor($color1, $color1);
     switch ($color1) {
         case Color::RED():
             echo 'red' . "\n";
             break;
         case Color::ORANGE():
             echo 'orange' . "\n";
             break;
         case Color::YELLOW():
             echo 'yellow' . "\n";
             break;
         case Color::GREEN():
             echo 'green' . "\n";
             break;
         case Color::BLUE():
             echo 'blue' . "\n";
             break;
         case Color::INDIGO():
             echo 'indigo' . "\n";
             break;
         case Color::VIOLET():
             echo 'violet' . "\n";
             break;
     }
     try {
         $invalidColor = Color::BLACK();
     } catch (\BadFunctionCallException $e) {
         echo 'error : ' . $e->getMessage() . "\n";
     }
 }
开发者ID:guoyu07,项目名称:PHPEnum-1,代码行数:41,代码来源:example-001.php

示例2: saySomethingNice

    }
    // Leverage built-in __toString() implementation for $color2.
    echo $color1->getName() . $comparison_result . $color2 . "<br />\n";
}
// Run demonstrations.
echo "<h2>Say Nice Stuff</h2>";
saySomethingNice(Color::BLUE());
saySomethingNice(Color::RED());
saySomethingNice(Color::YELLOW());
echo "<h2>List html codes</h2>";
listHtmlCodes();
echo "<h2>Compare colors</h2>";
compareColors(Color::RED(), Color::BLUE());
compareColors(Color::YELLOW(), Color::YELLOW());
$serialCopyColor = unserialize(serialize(Color::YELLOW()));
if ($serialCopyColor === Color::YELLOW()) {
    echo "\nunexected === match on serialized/deserialized value\n";
} else {
    echo "\n Expected === mismatch on serialized/deserialized value\n";
}
switch ($serialCopyColor) {
    case Color::YELLOW():
        echo "case match!\n";
        break;
    case Color::BLACK():
        echo "case false positive!\n";
        break;
    default:
        echo "case false negative!\n";
        break;
}
开发者ID:crussell52,项目名称:php-enum,代码行数:31,代码来源:example.php


注:本文中的Color::YELLOW方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。