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
 [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-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 09:01:24 2020 UTC