php-general Digest 13 Jun 2011 21:17:57 -0000 Issue 7356
Topics (messages 313498 through 313506):
Re: [pmwiki-users] debugging using error_log stuff
313498 by: Tamara Temple
313499 by: Tamara Temple
Getting File Owner Name
313500 by: Floyd Resler
313501 by: Jim Giner
Uncatchable errors
313502 by: Paul M Foster
313503 by: Stuart Dallas
313505 by: David Harkness
date.timezone set and still getting strict warnings.
313504 by: Tamara Temple
313506 by: Daniel Brown
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 Jun 13, 2011, at 4:05 AM, Richard Quadling wrote:
On 12 June 2011 22:57, Tamara Temple <[email protected]> wrote:
On Jun 12, 2011, at 4:32 PM, Peter Bowers wrote:
On Sun, Jun 12, 2011 at 3:18 PM, Tamara Temple <[email protected]
>
wrote:
function sms($text,$switch=0){
global $MessagesFmt;
error_log(date(DATE_RFC822)." Entered sms. text=$text.
switch=$switch\n",3,"/var/log/pmwiki/error.log");
if ($switch == true || is_array($text)) {
$MessagesFmt[] = "<pre>" . print_r($text,true) .
"</pre>\n";
} else {
$MessagesFmt[] = $text . "<br />\n";
}
# error_log(date(DATE_RFC822)." Exit sms.\n");
error_log(date(DATE_RFC822)." Exit
sms.\n",3,"/var/log/pmwiki/error.log");
}
Missing arguments #2 and #3 -- try as modified above.
-Peter
D'oh. Sometimes you stare and stare and stare at something and you
still
don't see it. Thanks a bunch.
Would the use of ...
error_reporting(-1);
ini_set('display_errors', 1);
have helped during your development?
I'm not sure it would have in this case, as there were no errors from
the PHP side of things -- what I had done was perfectly acceptable to
PHP. error_log doesn't require the last 2 arguments and did send the
message to the PHP error log with no problems. I just wasn't looking
there...
I do set those values when I'm developing and testing an application
typically, though, so that is good advice in general.
--- End Message ---
--- Begin Message ---
On Jun 13, 2011, at 11:59 AM, Tamara Temple wrote:
On Jun 13, 2011, at 4:05 AM, Richard Quadling wrote:
On 12 June 2011 22:57, Tamara Temple <[email protected]> wrote:
On Jun 12, 2011, at 4:32 PM, Peter Bowers wrote:
On Sun, Jun 12, 2011 at 3:18 PM, Tamara Temple <[email protected]
>
wrote:
function sms($text,$switch=0){
global $MessagesFmt;
error_log(date(DATE_RFC822)." Entered sms. text=$text.
switch=$switch\n",3,"/var/log/pmwiki/error.log");
if ($switch == true || is_array($text)) {
$MessagesFmt[] = "<pre>" . print_r($text,true) .
"</pre>\n";
} else {
$MessagesFmt[] = $text . "<br />\n";
}
# error_log(date(DATE_RFC822)." Exit sms.\n");
error_log(date(DATE_RFC822)." Exit
sms.\n",3,"/var/log/pmwiki/error.log");
}
Missing arguments #2 and #3 -- try as modified above.
-Peter
D'oh. Sometimes you stare and stare and stare at something and you
still
don't see it. Thanks a bunch.
Would the use of ...
error_reporting(-1);
ini_set('display_errors', 1);
have helped during your development?
I'm not sure it would have in this case, as there were no errors
from the PHP side of things -- what I had done was perfectly
acceptable to PHP. error_log doesn't require the last 2 arguments
and did send the message to the PHP error log with no problems. I
just wasn't looking there...
I do set those values when I'm developing and testing an application
typically, though, so that is good advice in general.
It's not Friday, but a general discussion of testing and debugging PHP
might be a good thing, no?
--- End Message ---
--- Begin Message ---
Is there a way I can get the name of a file's owner. I know I can get the
username by doing this:
posix_getpwuid(fileowner($filename));
How can I get the actual name of the owner?
Thanks!
Floyd
--- End Message ---
--- Begin Message ---
fileowner returns the username OF the file's OWNER. Isn't that what you
want? You don't think you're going to get their first and last name do you?
"Floyd Resler" <[email protected]> wrote in message
news:[email protected]...
Is there a way I can get the name of a file's owner. I know I can get the
username by doing this:
posix_getpwuid(fileowner($filename));
How can I get the actual name of the owner?
Thanks!
Floyd
--- End Message ---
--- Begin Message ---
There's certain class of errors which happen before any error-handler
(set_error_handler) can catch them, like parse errors and such. Is there
a way to have these generate the same type of response as the errors
handled by set_error_handler()? In my case, the error handler emails me
a summary and trace of the error. Any way to have things like parse
errors do the same thing?
Pointers to prior threads would do fine.
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--- End Message ---
--- Begin Message ---
On Mon, Jun 13, 2011 at 8:52 PM, Paul M Foster <[email protected]>wrote:
> There's certain class of errors which happen before any error-handler
> (set_error_handler) can catch them, like parse errors and such. Is there
> a way to have these generate the same type of response as the errors
> handled by set_error_handler()? In my case, the error handler emails me
> a summary and trace of the error. Any way to have things like parse
> errors do the same thing?
>
> Pointers to prior threads would do fine.
>
The only way to do this is to run your PHP script inside another process
(PHP or otherwise), piping the output accordingly so you can detect errors
that cannot be caught by the error handler.
However, statically detectable issues such as parse errors should never get
as far as a dynamic environment outside of your development machine, so I
would question why you have this requirement.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
On Mon, Jun 13, 2011 at 12:52 PM, Paul M Foster <[email protected]>
wrote:
>
> There's certain class of errors which happen before any error-handler
> (set_error_handler) can catch them, like parse errors and such. Is there
> a way to have these generate the same type of response as the errors
> handled by set_error_handler()?
You can use register_shutdown_function() [1] and error_get_last() [2] to
check if the last error type is one of the fatal errors. Here's a simple
example:
function shutdown() {
$error = error_get_last();
if ($error['type'] === E_ERROR) {
// fatal error has occured
}
}
register_shutdown_function('shutdown');
There are at least four fatal error types to check for. See [3] and [4] for
the list and links to more examples.
Peace,
David
[1] http://php.net/manual/en/function.register-shutdown-function.php
[2] http://php.net/manual/en/function.error-get-last.php
[3]
http://stackoverflow.com/questions/3108361/php-is-there-a-way-to-redirect-to-an-error-page-in-register-shutdown-function
[4]
http://stackoverflow.com/questions/4410632/handle-fatal-errors-in-php-using-register-shutdown-function
--- End Message ---
--- Begin Message ---
I have date.timezone set, as shown in the phpinfo() output:
portfolio:Downloads tamara$ php -r 'phpinfo();' | grep 'timezone'
Default timezone => America/Chicago
date.timezone => 'America/Chicago' => 'America/Chicago'
Yet, when I call a function like strtotime(), i still get the Strict
warning about not having date.timezone set. (Yes, I have restarted the
server, twice, and the correct value shows up if I invoke phpinfo()
via the server.)
Any clues?
--- End Message ---
--- Begin Message ---
On Mon, Jun 13, 2011 at 16:25, Tamara Temple <[email protected]> wrote:
> I have date.timezone set, as shown in the phpinfo() output:
>
> portfolio:Downloads tamara$ php -r 'phpinfo();' | grep 'timezone'
> Default timezone => America/Chicago
> date.timezone => 'America/Chicago' => 'America/Chicago'
That's the CLI version of PHP....
> Yet, when I call a function like strtotime(), i still get the Strict warning
> about not having date.timezone set. (Yes, I have restarted the server,
> twice, and the correct value shows up if I invoke phpinfo() via the server.)
.... and you're referencing the web version here.
> Any clues?
Check the web version of PHP's phpinfo() output and see if it and
the CLI are using the same php.ini file. My guess is that they're
not, and - while the CLI one is set with the timezone - its web
counterpart is missing the flag.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---