|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #32734 Support for #line pragma, as in C and Perl
Submitted: 2005-04-17 08:47 UTC Modified: 2017-09-27 15:51 UTC
Avg. Score:4.2 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: php at koterov dot ru Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: 5.0.4 OS: all
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: php at koterov dot ru
New email:
PHP Version: OS:


 [2005-04-17 08:47 UTC] php at koterov dot ru
C, C++ and Perl support the folowing feature:

// start of file
#line 20 "test.c"
#line 30 "test.c"
// end of file

If error is generated into code "something", it is reported as error "in test.c on line 20" - NOT on line 3! For code "other" - "in test.c on line 30". The same Perl code example:

### start of file
#line 20 "test.c"
warn "something";
#line 30 "test.c"
warn "other";
### end of file

Result is:

something at test.c line 20.
other at test.c line 30.

Unfortunately PHP does not support this useful feature, and because of that any template engines with pre-compilation (e.g. Smarty) make the life not so pleasant as it could be.

Do you plan to add #line feature in future versions of PHP? Programmers need it very much!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-10 19:35 UTC] rasmus at mindplay dot dk
This feature is badly lacking to support many good, modern patterns, which could broaden the scope and use of PHP in general. View-engines as mentioned, but not least aspect-oriented programming, code generation and meta-programming in general, and cross-language-compilation from other languages.

Microsoft's C# compiler has an implementation of this feature that could be referenced:

I would propose extending the existing syntax for execution directives, as implemented by the declare keyword:

It might looks like this:

  // start of file
  declare(source='test.c#30') {
  // end of file

Consistent with the way declare otherwise works - the first declare-statement in this example changes the error-reporting for all of the following statements in that file, while the second declare-statement changes the error reporting within the brackets.

I think this idea should be taken into serious consideration, as it has the potential to open up the world of PHP to entirely new forms of development.
 [2016-12-30 22:53 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2017-09-27 15:51 UTC]
-Status: Open +Status: Suspended
 [2017-09-27 15:51 UTC]
Thank you for your interest in PHP and for submitting a feature request. Please
be aware that due to the magnitude of change this request requires, it would be
necessary to discuss it on PHP Internals list ( as an
RFC. Please read the guide about creating RFCs here:
<>. If you haven't had experience with writing
RFCs before, it is advised to seek guidance on the Internals list
(<>) and/or solicit help from one of the
experienced developers. 

Please do not consider this comment as a negative view on the merits of your
proposal – every proposal which requires changes of certain magnitude, even the
very successful and widely supported ones, must be done through the RFC process.
This helps make the process predictable, transparent and accessible to all
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 23:03:35 2021 UTC