php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44566 Incorrect variable assignment doesn't cause parse error
Submitted: 2008-03-30 00:50 UTC Modified: 2008-03-30 14:02 UTC
From: Jonathon dot Reinhart at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.5 OS: Linux (Suse 10.2)
Private report: No CVE-ID: None
 [2008-03-30 00:50 UTC] Jonathon dot Reinhart at gmail dot com
Description:
------------
Simply putting a dollar sign ($) with no variable name afterwards, and no semicolon does not cause any error.

Reproduce code:
---------------
Example 1 (Gives no error):
<?php
$a = $
$b = 1;
?>

Example 2
Notice: Undefined variable: b in /srv/test2/htdocs/phpbug.php on line 4
<?php
error_reporting(E_ALL | E_STRICT);
$a = $
$b = 1;
?>

Expected result:
----------------
Expected to see a parse error on line 2 of Example 1.  Wouldn't expect the parser to continue looking after a "$" for a variable name after a "\n".

Actual result:
--------------
No error in Example 1.  Incorrect error in Example 2.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-30 14:02 UTC] derick@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

No bug, it\'s just parsed like:

$a = $$b = 1;
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Dec 16 11:00:01 2025 UTC