|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70344 extract skips valid variable names
Submitted: 2015-08-24 14:36 UTC Modified: 2015-09-03 01:41 UTC
From: Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: Irrelevant OS: N/A
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.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2015-08-24 14:36 UTC]
The extract function skips setting variables that have names that are valid but cannot be written as a simple variable.

For example, anything with dots can be written and accessed as a variable like:

${'some.config.setting'} = 'foo';

But extract considers anything with a dot in to be an invalid variable name, and so skips doing:

extract(['some.config.setting'} => 'foo']);

fails to extract it.

Test script:
$values = [
    '' => 'set from array',


if (!isset(${''})) {
    echo "It's not set\n";
else {

${''} = "It is a valid variable name, just not one that can be written as a non-interpolated variable.";

Expected result:
string(14) "set from array"

Actual result:
It's not set


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-24 15:32 UTC]
FWIW, the PHP manual defines[1]:

| Variable names follow the same rules as other labels in PHP. A
| valid variable 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]*'

[1] <>
 [2015-09-03 01:41 UTC]
We may add warning or notice for invalid key(var name).
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 22:01:30 2024 UTC