php equivalent to printf("%d/n",__LINE__);
am 31.01.2008 23:21:21 von Sandy.Pittendrigh
In C you can make debug statments that announce the current
line number in the source, with something like:
printf("%d\n",__LINE__);
php (if php.ini is setup that way) often announces
line numbers when catching errors.
How can you do echo the equivalent of C's __LINE__ macro
on non-error but interesting debugging conditions?
If ($checkbook-balance < $100 && $subject == "wife")
echo sys_sourceline(), "
"; ....or some such
Re: php equivalent to printf("%d/n",__LINE__);
am 31.01.2008 23:34:40 von ivansanchez-alg
salmobytes wrote:
> In C you can make debug statments that announce the current
> line number in the source, with something like:
> printf("%d\n",__LINE__);
>
> How can you do echo the equivalent of C's __LINE__ macro
> on non-error but interesting debugging conditions?
Surprise! You can do that with:
printf("%d\n",__LINE__);
?>
Or you can use the shorter
Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
Conscience doth make cowards of us all.
-- Shakespeare
Re: php equivalent to printf("%d/n",__LINE__);
am 01.02.2008 00:50:38 von axlq
In article <8cafc0ed-306b-405f-b9bc-94f8f7d4b116@i3g2000hsf.googlegroups.com>,
salmobytes wrote:
>In C you can make debug statments that announce the current
>line number in the source, with something like:
> printf("%d\n",__LINE__);
>
>php (if php.ini is setup that way) often announces
>line numbers when catching errors.
>
>How can you do echo the equivalent of C's __LINE__ macro
>on non-error but interesting debugging conditions?
Easy, just use __LINE__. Surprised?
I use the __FILE__, __FUNCTION__, and __LINE__ constantly in my php
code, especially with database queries, which often go awry while
developing a web site. I have multiple class libraries and code
modules. All my database queries are handled by a 'SQL_operations'
class, and every method gets __FILE__, __FUNCTION__, and __LINE__
passed to it, so if any error occurs, I am emailed the details.
-A