Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef1a12e

Browse files
marc-mabemarc-bennewitz@arcor.de
authored andcommitted
Change boolean constnats
1 parent af70cac commit ef1a12e

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
php-behaviour
2-
=============
3-
41
List of PHP behaviours you don't expect
2+
=======================================
3+
4+
* String/Integer/Resource comparison
5+
* [Change boolean constants TRUE/FALSE](change_boolean_constants.md)
6+
* Type conversion on array keys
7+
* Late constants linking
8+
* Reference returning

change_boolean_constants.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Change boolean constants TRUE/FALSE (within a namespace)
2+
========================================================
3+
4+
Example:
5+
--------
6+
(http://3v4l.org/hq7Jj)
7+
8+
Because TRUE and FALSE are constants of the root namespace
9+
you can define your own constants within another namespace.
10+
11+
```php
12+
namespace Foo;
13+
define('Foo\\true', \false);
14+
define('Foo\\false', \true);
15+
16+
var_dump(array(
17+
'true' => true,
18+
'false' => false,
19+
'1===1' => 1===1,
20+
'1!==1' => 1!==1,
21+
));
22+
```
23+
24+
```
25+
array(4) {
26+
["true"] => bool(false),
27+
["false"] => bool(true),
28+
["1===1"] => bool(true),
29+
|"1!==1"] => bool(false)
30+
}
31+
```

0 commit comments

Comments
 (0)