ID: 45111 User updated by: php at koterov dot ru Reported By: php at koterov dot ru Status: Open Bug Type: Feature/Change Request Operating System: all PHP Version: 5.2.6 New Comment:
I have dug the PHP source code a little. Hmm, seems this feature is not too easy to implement... Line number is stored in znode, it's easy to substitute. But filename is stored in zend_op_array, NOT in zend_op. So, for a sequence of opcodes grouped by a single zend_op_array there is no chance to specify different filenames. (Of course I could add a field to zend_op, but in this case all accelerators like eAccelerator seem to stop working, because they know nothing about this field and do not store/restore it.) Am I right? Previous Comments: ------------------------------------------------------------------------ [2008-05-27 22:54:09] php at koterov dot ru Description: ------------ In Perl, we could write the following program test.pl (lines are enumerated for better look): 01 #!/usr/bin/perl -w 02 print "hello!\n"; 03 print "something!\n"; 04 05 #line 100 "aaa.pl" 06 print $undefined_var; This code generates a warning message "Using of undefined variable", but (attention!) - the context of this error is NOT "test.pl line 5", but - "aaa.pl line 100". So, the "pseudo-comment" operator #line xxx "yyy" in Perl substitutes the current parsing context to a specified line number and filename. (You may ommit filename, then - only the line number will be substituted). And, if a warning or a fatal error occurs, the line number and filename in the error message will be changed. There is the same feature in C language: it is used by C preprocessor to execute #include directives an keep line numbers clear to understand. This feature is VERY VERY useful when we write some code translator (e.g. from a templating language to pure PHP). This kind of translation is done e.g. in Smarty: it translates Smarty templates into pure PHP code, but line numbers are mixed up in translated files, so we cannot revert back and detect which line of the template had produced an error. Please say, do you plan to add this feature to a new PHP versions? I'd like to ask you very much about it... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45111&edit=1