php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55321 PHP Notice: Use of undefined constant self
Submitted: 2011-07-29 22:13 UTC Modified: 2011-07-30 18:49 UTC
From: deminy at deminy dot net Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.3.6 OS: Ubuntu 11.04 (64 bit)
Private report: No CVE-ID: None
 [2011-07-29 22:13 UTC] deminy at deminy dot net
Description:
------------
When running the test script with PHP 5.3.6 (and PHP 5.3.5) on Ubuntu 11.04 (64 bit) from command line, following message shown up.

PHP Notice:  Use of undefined constant self - assumed 'self' in /path_to_the_PHP_script on line 5
PHP Stack trace:
PHP   1. {main}() /path_to_the_PHP_script:0
PHP   2. TestArray::flatten() /path_to_the_PHP_script:25

The test script runs fine with PHP 5.3.5 on Ubuntu 11.04 (32 bit).

Test script:
---------------
<?php
class TestArray {
	public static function flatten(array $arr) {
		$data = array();
		array_walk_recursive($arr, array(self, 'appendToArray'), &$data);
		return $data;
	}

	protected static function appendToArray($val, $key, array &$arr) {
		$arr[] = $val;
	}
}

$arr = array(
	'a',
	array(
		'b',
		array(
			'c',
			'd',
		),
	),
);

print_r(TestArray::flatten($arr));
?>


Expected result:
----------------
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
)


Actual result:
--------------
PHP Notice:  Use of undefined constant self - assumed 'self' in /path_to_the_PHP_script on line 5
PHP Stack trace:
PHP   1. {main}() /path_to_the_PHP_script:0
PHP   2. TestArray::flatten() /path_to_the_PHP_script:25
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-30 18:49 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-07-30 18:49 UTC] cataphract@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 16:01:31 2024 UTC