Products Resources Support About Us

PHP 5.4.4 Incorrect line number reported when error occurs

PHP 5.4.4 Build Date Nov 21 2016 03:23:06 running on z/OS 2.2 under Apache V9.

It seems that PHP does not take into account the she-bang on the first line when reporting the line number in error, therefore it is always one less than its actual location in the script. The following example code contains a syntax error on line 7:

000001 #!/path/to/php/php-cgi
000002 <?php
000003
000004 $v = “A value”;
000005
000006 // The following line contains a syntax error
000007 $a = arra();
000008
000009 ?>

When run in the browser the following message is displayed:

Fatal error: Call to undefined function arra() in /my/cgi on line 6

Notice that the reported line number is “6” when the actual error occurs on source line “7”.

If the same script is run using PHP 5.1.2 (previously supplied by IBM) then this message is displayed:

Fatal error: HPH01209 Call to undefined function arra() in /my/cgi on line 7

Now the correct line number is displayed.

I guess it’s debatable as to whether or not the she-bang should be counted when calculating the line number but it sure makes debugging easier if the reported line number matches the source exactly.

Any chance that this could be changed or is there a setting somewhere to make it happen?

Thanks.

Thanks for reporting this problem. We are in the midst of testing an entirely new port of PHP 7.0.5. We need to make a judgement call as to whether we will patch v5.4.4 or only to ensure v7.0.5 does not exhibit this behavior. Back to you in a couple of days.
Regards,
-Peter

This problem also manifests with same PHP 5.4.4 on Ubuntu. Thus this is not specific to the z/OS port.

Yes, it does appear that the incorrect line number is a PHP issue.

I found some evidence that this has been reported, at least for phpdbg:

https://bugs.php.net/bug.php?id=73704

I don’t know if this affects PHP itself but it looks as though 7.0.14 is the level for which it was reported. I haven’t (yet) tried PHP 7.1.2 to see if it is resolved here.