|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-02-09 09:15 UTC] ivan dot enderlin at hoa-project dot net
Description:
------------
Hey :-),
Just a noticeable think that PHP allows is the use of non-breaking space (0x00A0) as a valid identifier character. Thus, we can have very strange code (but I love it)! See bellow.
It is not a bug, just a fact that makes PHP awesome.
Test script:
---------------
<?php
// Just for fun.
class Aa Bb Cc {
public function f g h ( ) {
var_dump('succeed (1)');
}
}
$c l a s s = new Aa Bb Cc();
$c l a s s->f g h();
// Go deeper.
function ( ) {
var_dump('succeed (2)');
}
();
// Go crazy!
class {
public function ( ) {
var_dump('succeed (3)');
}
}
$ = new ();
$ -> ();
echo 'PHP is awesome :-).' . "\n";
Expected result:
----------------
string(11) "succeed (1)"
string(11) "succeed (2)"
string(11) "succeed (3)"
PHP is awesome :-).
Actual result:
--------------
string(11) "succeed (1)"
string(11) "succeed (2)"
string(11) "succeed (3)"
PHP is awesome :-).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 14:00:01 2025 UTC |
Description: ------------ Hey :-), Just a noticeable thing that PHP allows is the use of non-breaking space (0x00A0) as a valid identifier character. Thus, we can have very strange code (but I love it)! See bellow. It is not a bug, just a fact that makes PHP awesome. Test script: --------------- <?php // Just for fun. class Aa Bb Cc { public function f g h ( ) { var_dump('succeed (1)'); } } $c l a s s = new Aa Bb Cc(); $c l a s s->f g h(); // Go deeper. function ( ) { var_dump('succeed (2)'); } (); // Go crazy! class { public function ( ) { var_dump('succeed (3)'); } } $ = new (); $ -> (); echo 'PHP is awesome :-).' . "\n"; Expected result: ---------------- string(11) "succeed (1)" string(11) "succeed (2)" string(11) "succeed (3)" PHP is awesome :-). Actual result: -------------- string(11) "succeed (1)" string(11) "succeed (2)" string(11) "succeed (3)" PHP is awesome :-).