本文整理汇总了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";
}
}
示例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;
}