php equivalent to printf("%d\n",__LINE__);
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(), "<br>"; ....or some such
Re: php equivalent to printf("%d\n",__LINE__);
I forgot to mention this in my previous reply:
http://php.net/manual/en/language.constants.predefined.php
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
Toda pulgada cúbica de espacio es un milagro.- Walt Whitman.
Re: php equivalent to printf("%d\n",__LINE__);
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:
<?php
printf("%d\n",__LINE__);
?>
Or you can use the shorter <?php echo __LINE__; ?>
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__);
In article <8cafc0ed-306b-405f-b9bc-94f8f7d4b116 [at] i3g2000hsf.googlegroups.com>,
salmobytes <Sandy.Pittendrigh [at] gmail.com> 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