|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54081 __LINE__ provides unexpected value
Submitted: 2011-02-23 18:06 UTC Modified: 2015-03-03 03:55 UTC
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: rmroczk at searshc dot com Assigned:
Status: Duplicate Package: CGI/CLI related
PHP Version: 5.3.5 OS: ubuntu
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: rmroczk at searshc dot com
New email:
PHP Version: OS:


 [2011-02-23 18:06 UTC] rmroczk at searshc dot com
This issue is very similar to Bug #20035 but the difference is in the #! line.
I am trying to find a way to specify the #! line, including the -d option such that the value of __LINE__ is correct.

Test script:
$ php5 -dauto_prepend_file=auto_prepend.php <test.php #correct value of __LINE__
Line: 2
#!/usr/bin/php5 -dauto_prepend_file=auto_prepend.php
Line: 7

$ ./test.php #incorrect value of __LINE__
Line: 3
Line: 6

$ php5 -dauto_prepend_file=auto_prepend.php test.php #incorrect
Line: 3
Line: 6
$ cat auto_prepend.php
echo "Line: " . __LINE__ . "\n";
$ cat test.php
#!/usr/bin/php5 -dauto_prepend_file=auto_prepend.php
function function_name() {
function function_name2() {
echo "Line: " . __LINE__ . "\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-03 03:55 UTC]
-Status: Open +Status: Duplicate
 [2015-03-03 03:55 UTC]
Dup of bug and been fixed in PHP5.5+
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Oct 04 11:01:25 2023 UTC