php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43140 Error in parser
Submitted: 2007-10-30 12:09 UTC Modified: 2007-10-30 16:48 UTC
From: felipensp at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-10-30 (snap) OS: Linux
Private report: No CVE-ID: None
 [2007-10-30 12:09 UTC] felipensp at gmail dot com
Description:
------------
Parser recognize wrong the array parameter.
It see array(..) as (array).

Reproduce code:
---------------
$a = create_function(array(1), 'print 1;');

Expected result:
----------------
Parse error: syntax error, unexpected T_ARRAY, expecting '&' or T_VARIABLE

Actual result:
--------------
Parse error: syntax error, unexpected T_ARRAY_CAST, expecting '(' in /home/felipe/public_html/bug.php(4) : runtime-created function

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-30 16:48 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

create_fucntion($params, $code) actually is eval(\"function lambda1($params) { $code }\"). In your code $params is an Array which is being casted to a string \"Array\" so the full code reads like
   function lambda(Array) { print1; }
where the error message is misleading but correct.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 08:01:30 2025 UTC