php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70586 When i try ${'_'.'POST'} i get: Notice: Undefined variable: _POST in
Submitted: 2015-09-25 20:46 UTC Modified: 2015-12-19 10:26 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: DAVIDhaker at yandex dot ru Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.6.14RC1 OS: Windows 10 Pro x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: DAVIDhaker at yandex dot ru
New email:
PHP Version: OS:

 

 [2015-09-25 20:46 UTC] DAVIDhaker at yandex dot ru
Description:
------------
When i try ${'_'.'POST'} in object __call i get: Notice: Undefined variable: _POST in ...

Test script:
---------------
<?php
	class A {
		public function __call($method, $args){
			var_dump($_POST, ${'_POST'}, ${'_'.'POST'}, '_POST' == '_'.'POST', $_POST == ${'_POST'});
		}
	}
	$class = new A();
	$class->test();

Expected result:
----------------
array(0) { } array(0) { } NULL bool(true) bool(true)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 04:14 UTC] ajf@php.net
Looks like it's fixed in PHP 7: https://3v4l.org/u5Snj

Also seems to indeed be specific to `__call` within a class. I don't get this for just var_dump() at top-level.
 [2015-12-19 04:14 UTC] ajf@php.net
-Status: Open +Status: Verified
 [2015-12-19 10:26 UTC] nikic@php.net
-Status: Verified +Status: Not a bug
 [2015-12-19 10:26 UTC] nikic@php.net
Accessing super globals through variable variables is undefined behavior. It may or may not work depending on whether the variable name is evaluated at compile-time or not.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC