php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47920 how about changing...
Submitted: 2009-04-08 02:44 UTC Modified: 2009-04-08 20:04 UTC
From: odarcan at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.3.0RC1 OS: all
Private report: No CVE-ID: None
 [2009-04-08 02:44 UTC] odarcan at gmail dot com
Description:
------------
the Parse error: syntax error, unexpected T_VARIABLE in C:\Lighty\HTDOCS\3.php on line 58

to:

"You forgot a ';' dear user!"

Reproduce code:
---------------
<?php
$a=5
$b=4;

Expected result:
----------------
You forgot a ';' dear user!

Actual result:
--------------
Parse error: syntax error, unexpected T_VARIABLE in C:\Lighty\HTDOCS\3.php on line 58

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-08 17:59 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

That's not that easy, you might also miss a "+" or something completely different.
 [2009-04-08 18:39 UTC] odarcan at gmail dot com
i suggest you rethink
this is a feature request.

if all lines end with ; except for one.. and php is about to give a syntax error for the next line, you can be damn sure that a ; is missing.

submit=send
 [2009-04-08 20:04 UTC] rasmus@php.net
The parser isn't line-oriented though.  

This is perfectly valid, for example:

$a =
$b =
$c = 0;

but this isn't:

$a = 1
$b = 
$c = 0;

Here we get "syntax error, unexpected T_VARIABLE" when it hits the $b there which is perfectly correct.  Throwing an error that assumes something that isn't there, a ';' at the end of the first line in this example, doesn't make any sense.  All we can do is throw an error when we hit something that doesn't fit in the grammar.  That is how all parsers work.  They match text to a grammar and throw an error when it doesn't match.  Trying to make the error handler guess how the code could be modified to make it valid is much too hard and error-prone.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 08:01:29 2024 UTC