/    Sign up×
Community /Pin to ProfileBookmark

how get current line in php?

hi,
we have a msg that display the line number on error handler now i want know is there is a way to see the current line at normal operation for debug operation.
thanks for your help
?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ZnupiDec 13.2008 — Check out [url=http://www.php.net/manual/en/language.constants.predefined.php]magic constants[/url] ?.
Copy linkTweet thisAlerts:
@NogDogDec 13.2008 — You might possibly also want to take a look at [url=http://php.net/debug_backtrace[/url]debug_backtrace[/url]() and [url=http://php.net/debug_print_backtrace]debug_print_backtrace[/url]().
Copy linkTweet thisAlerts:
@jasonx22authorDec 17.2008 — hi,

both ways is available on php 4.2?

thanks
Copy linkTweet thisAlerts:
@jasonx22authorDec 17.2008 — hi,

i have tried this:

print_r(debug_backtrace());


and the result is this:

Array ( [0] => Array ( [file] => path [line] => 303 [function] => require_once ) )

there is no way to return less information?

thanks ?
Copy linkTweet thisAlerts:
@NogDogDec 17.2008 — You can grab whatever part(s) of the backtrace array you want:
[code=php]
$debug = debug_backtrace();
echo "Error at line " . $debug['line'] . " in file " . $debug['file'];
[/code]

It all depends on what you want to do. And in the above case, if that's all you want, it's simpler to just do:
[code=php]
echo "Error at line " . __LINE__ . " in file " . __FILE__;
[/code]
×

Success!

Help @jasonx22 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...