Possible PHP Bug With const?
Posted: Mon Oct 19, 2009 11:24 am
Hi,
I don't know if this is supposed to happen or not...but check this out:
This is quite annoying, because I need to use the or operator in one of my class constants. I could just add the values up...but this makes more sense - next time I go back to look over my code, instead of seeing a random number and wondering what it's for, I'll see the comparison.
So yeah, has anyone ever come across something similar, or even better, know a way to fix it?
Thanks, Jack.
I don't know if this is supposed to happen or not...but check this out:
Code: Select all
<?php
define('one', 1); // one will be 1
const two = 2; // two will be 2 (as of php 5.3)
define('one_or_two', 1 | 2); // one_or_two will be 3
const two_or_three = 2 | 3; // error
?>So yeah, has anyone ever come across something similar, or even better, know a way to fix it?
Thanks, Jack.