Click to See Complete Forum and Search --> : Output filename and line number


sleeping
October 11th, 2004, 01:52 PM
Using PHP 4.1.2, is there a function that allows you to print the file line number and the filename where the function is called?

I'd like to have an error reporting tool in the likes of :


// (file lang.php)

24 | switch($language)
25 | {
26 | case 'en' :
27 | // do something
28 | break ;
29 | case 'fr' :
30 | // do something
31 | break ;
32 | default:
33 | print "No language selected in " . print_file_name() . " on line " . print_line_number() . "<BR>\n";


The output would then be :


No language selected in lang.php on line 33


Is such a thing possible in PHP?

Davey
October 11th, 2004, 04:52 PM
I think this may be what you want.

http://www.php.net/manual/en/language.constants.predefined.php

PallaviDalvi
October 12th, 2004, 03:59 AM
Thanx Davey...that was something i wasnt aware of... very very interesting!

sleeping
October 12th, 2004, 10:50 AM
I think this may be what you want.

http://www.php.net/manual/en/language.constants.predefined.php

Ahhhh... great. This is exactly what I was looking for. Thanks a bunch. :)