Skip to content

Instantly share code, notes, and snippets.

@Sankame
Last active May 27, 2016 16:08
Show Gist options
  • Save Sankame/46005a2dc4fed64a807f9c15cbb8c010 to your computer and use it in GitHub Desktop.
Save Sankame/46005a2dc4fed64a807f9c15cbb8c010 to your computer and use it in GitHub Desktop.
XOR(排他的論理和)でトグルボタンを実装
<?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