display the line number of the statement being executed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
whacker
Forum Newbie
Posts: 2
Joined: Wed Jan 14, 2004 5:14 am

display the line number of the statement being executed

Post by whacker »

Help!!!

Is there a function or way a in php to display the line number of the current or last code or statement being executed aside from having an error???
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved to the PHP - Code forum.

Mac
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I'm a little confused by what you're asking? You can use __LINE__ to tell you what line you're on, e.g.:

Code: Select all

<?php
echo 'I am curently on line '.__LINE__;


echo '<br />';


echo 'Now I am on line '.__LINE__;
?>
outputs:

Code: Select all

I am curently on line 2
Now I am on line 8
Mac
whacker
Forum Newbie
Posts: 2
Joined: Wed Jan 14, 2004 5:14 am

Post by whacker »

Thank you. It solved my problem.

Forgive me if I have anohter question: How about the current php file executed even if it just an include file?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

__FILE__

Mac
Post Reply