php-general Digest 13 Apr 2011 02:06:35 -0000 Issue 7271
Topics (messages 312355 through 312360):
Re: a shortcut to set variable
312355 by: David Harkness
312356 by: Richard Quadling
Debugging Help Needed
312357 by: Rich Shepard
312358 by: Daniel Brown
312359 by: Rich Shepard
312360 by: Paul M Foster
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Tue, Apr 12, 2011 at 6:34 AM, Richard Quadling <[email protected]>wrote:
> Without running the code, can you say what the output will be in the 3
> examples?
>
Yes, but I would still rewrite that code. ;) I typically reserve the ternary
operator to return a value or assign a variable. Given that it is used less
frequently combined with its precedence in PHP differing from other
languages make using it in complicated expressions prone to errors and
misunderstanding by others.
Adding parentheses avoids interpreter errors but doesn't lessen the
likelihood of another developer breaking the code if they modify it.
David
--- End Message ---
--- Begin Message ---
On 12 April 2011 20:00, David Harkness <[email protected]> wrote:
> On Tue, Apr 12, 2011 at 6:34 AM, Richard Quadling <[email protected]>
> wrote:
>>
>> Without running the code, can you say what the output will be in the 3
>> examples?
>
> Yes, but I would still rewrite that code. ;) I typically reserve the ternary
> operator to return a value or assign a variable. Given that it is used less
> frequently combined with its precedence in PHP differing from other
> languages make using it in complicated expressions prone to errors and
> misunderstanding by others.
> Adding parentheses avoids interpreter errors but doesn't lessen the
> likelihood of another developer breaking the code if they modify it.
> David
>
No matter what one developer uses a ternary for, it can be used as in
inline if/then/else.
And as such, not keeping track of the precedence is what will make for
some very interesting debugging exercise.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
I'm not a PHP coder, but I have an application written in PHP (CMS Made
Simple) that stopped working when I upgraded postgres to 9.x. I seem to have
most of the problems fixed (those with adodb_lite) but now need to track
down why I get a "404 Page Not Found" error when I try to invoke the local
application. BTW, I'm running php-5.2.17 on Slackware-13.1.
Running 'php index.php' from the application subdirectory to the document
root directory, I learn the code to search in the directory structure. It
turns out to be misc.functions.php, and the specific function in that file
is ErrorHandler404(). However, I have not been able to trace execution to
learn just where this function is being called.
Looking at the PHP manual I see there's a function called
debug_print_backtrace(), but I have not found how to properly use it. When I
insert it at the top of ErrorHandler404(), php throws an error when I try to
run index.php:
function ErrorHandler404()
{
debug_print_backtrace()
#if ($errno == E_USER_WARNING) {
@ob_end_clean();
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
produces:
PHP Parse error: syntax error, unexpected '@' in
/var/www/htdocs/cmsms/lib/misc.functions.php on line 223
How can I determine where ErrorHandler404() is being called so I can fix
the problem and get the application running again?
Rich
--- End Message ---
--- Begin Message ---
On Tue, Apr 12, 2011 at 18:29, Rich Shepard <[email protected]> wrote:
>
> Looking at the PHP manual I see there's a function called
> debug_print_backtrace(), but I have not found how to properly use it. When I
> insert it at the top of ErrorHandler404(), php throws an error when I try to
> run index.php:
>
> function ErrorHandler404()
> {
> debug_print_backtrace()
You missed the ending semicolon, that's all. So when this line comes up:
> @ob_end_clean();
PHP completely flips its lid and starts making threats against your life.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Tue, 12 Apr 2011, Daniel Brown wrote:
You missed the ending semicolon, that's all.
Daniel,
Oops! Too long since C and Python doesn't use semicolons.
Adding that, I remove the error but do not see the printed backtrace.
Please suggest how I can determine the source of the page not found error,
or how to capture output from debug_print_backtrace.
Thanks,
Rich
--- End Message ---
--- Begin Message ---
On Tue, Apr 12, 2011 at 03:37:26PM -0700, Rich Shepard wrote:
> On Tue, 12 Apr 2011, Daniel Brown wrote:
>
> > You missed the ending semicolon, that's all.
>
> Daniel,
>
> Oops! Too long since C and Python doesn't use semicolons.
Wait, what?! Did they change C? When did this happen?! ;-}
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--- End Message ---