Last active
May 27, 2016 16:08
-
-
Save Sankame/46005a2dc4fed64a807f9c15cbb8c010 to your computer and use it in GitHub Desktop.
XOR(排他的論理和)でトグルボタンを実装
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$button = 0; | |
// ボタンを押す。 | |
$button = $button ^ 1; | |
// 1になる。 | |
print 'ボタンの状態:' . $button . "\n"; | |
// ボタンを押す。 | |
$button = $button ^ 1; | |
// 0になる。 | |
print 'ボタンの状態:' . $button . "\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment