[PHP] Line Number function?

2003-02-01 Thread Benjamin Smith
PHP keeps track of what line# is being executed, so that when there's an 
error (say in pg_exec() ) it reports what line the error occured on. 

This appears to happen even during runtime (not just during compilation). 

For example: 
-
?
$dbname=mydb; 
$dbuser=myuser; 
$dbpass=mypw; 

$conn=pg_connect(dbname=$dbname, user=$dbuser, password=$dbpass); 
$cmd=go and ask the mice; 
$result=pg_exec($conn, $cmd); 
?
--

This would result in a pg_exec error ~ line 7. PHP tracks this, even though 
the error is during runtime, not during the precompile. 

Is there a function where I can access this information? Something like 
get_line(); or something? 

This would be REALLY HANDY for debugging large projects... 

-Ben 

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




RE: [PHP] Line Number function?

2003-02-01 Thread Steven Balthazor
I think what you are looking for is: 
__LINE__

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

Cheers,
Steven Balthazor

-Original Message-
From: Benjamin Smith [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, February 01, 2003 8:59 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Line Number function?


PHP keeps track of what line# is being executed, so that when there's an 
error (say in pg_exec() ) it reports what line the error occured on. 

This appears to happen even during runtime (not just during compilation). 

For example: 
-
?
$dbname=mydb; 
$dbuser=myuser; 
$dbpass=mypw; 

$conn=pg_connect(dbname=$dbname, user=$dbuser, password=$dbpass); 
$cmd=go and ask the mice; 
$result=pg_exec($conn, $cmd); 
?
--

This would result in a pg_exec error ~ line 7. PHP tracks this, even though 
the error is during runtime, not during the precompile. 

Is there a function where I can access this information? Something like 
get_line(); or something? 

This would be REALLY HANDY for debugging large projects... 

-Ben 

-- 
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] Line Number function?

2003-02-01 Thread Michael Sims
On Sat, 1 Feb 2003 19:59:00 -0800, you wrote:

PHP keeps track of what line# is being executed, so that when there's an 
error (say in pg_exec() ) it reports what line the error occured on. 
[...]
Is there a function where I can access this information? Something like 
get_line(); or something? 

Do you mean like the predefined constant __LINE__?

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

Sorry if I'm misunderstanding the question...

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




Re: [PHP] Line Number function?

2003-02-01 Thread Philip Olson
On Sun, 2 Feb 2003, Michael Sims wrote:

 On Sat, 1 Feb 2003 19:59:00 -0800, you wrote:
 
 PHP keeps track of what line# is being executed, so that when there's an 
 error (say in pg_exec() ) it reports what line the error occured on. 
 [...]
 Is there a function where I can access this information? Something like 
 get_line(); or something? 
 
 Do you mean like the predefined constant __LINE__?
 
 http://www.php.net/manual/en/language.constants.predefined.php

Yep, that will do it and has been available in PHP for a
very long time (along with __FILE__).  PHP 4.3.0 introduces
the following:

  __FUNCTION__   Function name
  __CLASS__  Class name
  debug_backtrace()  Debugging information including the
 line number

See: http://www.php.net/debug_backtrace

Regards,
Philip


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