php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53968 Non-breaking spaces are considered as a valid identifier character
Submitted: 2011-02-09 09:15 UTC Modified: 2011-02-11 13:37 UTC
From: ivan dot enderlin at hoa-project dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ivan dot enderlin at hoa-project dot net
New email:
PHP Version: OS:

 

 [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 :-).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-09 09:26 UTC] scottmac@php.net
-Status: Open +Status: Bogus
 [2011-02-09 09:26 UTC] scottmac@php.net
if its not a bug why report it here?
 [2011-02-09 09:27 UTC] ivan dot enderlin at hoa-project dot net
To alert developers and prove that it is not a bug :-).
 [2011-02-09 09:45 UTC] scottmac@php.net
It's in the manual.

A letter in PHP is considered to be a-z,A-Z and 0x7f-0xff
 [2011-02-09 10:07 UTC] ivan dot enderlin at hoa-project dot net
Yup I know it. I precise that it is not a bug, but if someone searches, thinking that it is a bug, he will probably find this “bug” and got its answer.
 [2011-02-11 13:37 UTC] ivan dot enderlin at hoa-project dot net
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 :-).
 [2011-02-11 13:38 UTC] ivan dot enderlin at hoa-project dot net
Oops, can't edit my description?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC