RE: [PHP] error reporting linenumber and filename[Scanned]

2003-06-16 Thread Michael Egan
Use the predefined constant:

__LINE__

Regards,

Michael Egan

-Original Message-
From: Bas Jobsen [mailto:[EMAIL PROTECTED]
Sent: 16 June 2003 12:50
To: PHP General
Subject: [PHP] error reporting linenumber and filename[Scanned]


Hi,

Running the code below, shows an errror in line 2 as expected.
How do i get the linenumber of the function call? 3 here.

?
function test($x){if($x!='a')trigger_error('error: call test with argument 1 
equals a',E_USER_ERROR);}
test('b');
?

Best regards,

Bas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] error reporting linenumber and filename[Scanned]

2003-06-16 Thread Bas Jobsen
Hi Michael,

 I'm not sure that there is a way beyond this to show the line within the
 function but I don't see that this would be necessary - at least not for
 resolving errors.

i'm building a class for html table, will give you a short example (see 
below).
Running testtable.php will produce Error: you can't open a new table on line 
13 on file /home/table.php, but i will get line 7 on testtable.php cause 
the wrong function is call there.

table.php:
--
?
class table
{
var $open;

function table()
{
$this-open=false;
}

function open()
{
if($this-open)echo 'Error: you can\'t open a new table on line 
'.__LINE__.' on file '.__FILE__;
else 
{
?table?
$this-open=true;
}

}
function close()
{
if(!$this-open)echo 'Error: you can\'t close a table which not open 
on 
line '.__LINE__.' on file '.__FILE__;
else 
{
?/table?
$this-open=false;
}   
}   
}   
?
--

testtable.php:
--
?
include('table.php');
$TABLE=new table;
$TABLE-open();
$TABLE-close();
$TABLE-open();
$TABLE-open();
?
--
 


Op maandag 16 juni 2003 15:10, schreef u:
 Bas,

 The __LINE__ constant will return the line number of the script from which
 the call is made.  This should be enough to isolate any error.

 I recently had a detailed look at the phpBB (www.phpbb.com)  application
 and they use their own 'message_die' function which ensures that whenever
 errors occur they give a detailed explanation of the error together with
 the file name ( __FILE__ ) and the line number which produced the error.

 I'm not sure that there is a way beyond this to show the line within the
 function but I don't see that this would be necessary - at least not for
 resolving errors.

 HTH,

 Michael Egan

 -Original Message-
 From: Bas Jobsen [mailto:[EMAIL PROTECTED]
 Sent: 16 June 2003 13:14
 To: Michael Egan
 Subject: Re: [PHP] error reporting linenumber and filename[Scanned]


 Dear Michael,

 Thanks for your respons, maybe i don't inderstand your solution but:

 1function line()
 2{
 3 echo __line__;
 4}
 5line();

 will print 3 and not 5

 best regards,

 Bas

 Op maandag 16 juni 2003 14:05, schreef u:
  Use the predefined constant:
 
  __LINE__
 
  Regards,
 
  Michael Egan
 
  -Original Message-
  From: Bas Jobsen [mailto:[EMAIL PROTECTED]
  Sent: 16 June 2003 12:50
  To: PHP General
  Subject: [PHP] error reporting linenumber and filename[Scanned]
 
 
  Hi,
 
  Running the code below, shows an errror in line 2 as expected.
  How do i get the linenumber of the function call? 3 here.
 
  ?
  function test($x){if($x!='a')trigger_error('error: call test with
  argument 1 equals a',E_USER_ERROR);}
  test('b');
  ?
 
  Best regards,
 
  Bas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] error reporting linenumber and filename[Scanned]

2003-06-16 Thread Ford, Mike [LSS]
 -Original Message-
 From: Bas Jobsen [mailto:[EMAIL PROTECTED]
 Sent: 16 June 2003 14:39
 
  I'm not sure that there is a way beyond this to show the 
 line within the
  function but I don't see that this would be necessary - at 
 least not for
  resolving errors.
 
 i'm building a class for html table, will give you a short 
 example (see 
 below).
 Running testtable.php will produce Error: you can't open a 
 new table on line 
 13 on file /home/table.php, but i will get line 7 on 
 testtable.php cause 
 the wrong function is call there.

If you're running PHP 4.3.0 or later, there's http://www.php.net/debug_backtrace which 
might help.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php