php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76984 class name with unicode characters are accepted
Submitted: 2018-10-09 13:01 UTC Modified: 2018-10-09 13:22 UTC
From: info at developiu dot it Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 7.1.22 OS: linux (centos 7)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 14 = ?
Subscribe to this entry?

 
 [2018-10-09 13:01 UTC] info at developiu dot it
Description:
------------
---
From manual page: http://www.php.net/language.oop5.basic
---

in this page it is said "The class name can be any valid label, provided it is not a PHP reserved word. A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$."

from the regular expression class names with unicode charaters shbould not be accepted, but this is not true.

Test script:
---------------
<?php

class Հ {}

var_dump(new Հ);

Expected result:
----------------
a parse error

Actual result:
--------------
class Հ#1 (0) {
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-09 13:22 UTC] salathe@php.net
-Status: Open +Status: Not a bug
 [2018-10-09 13:22 UTC] salathe@php.net
In UTF-8, the character Հ is encoded with the two bytes: \xD5 \x80 (https://www.compart.com/en/unicode/U+0540)
These bytes match the regex quoted from the manual.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 10:01:29 2024 UTC