php-general Digest 14 Nov 2012 12:08:15 -0000 Issue 8039

2012-11-14 Thread php-general-digest-help

php-general Digest 14 Nov 2012 12:08:15 - Issue 8039

Topics (messages 319703 through 319707):

Re: Date comparison going wrong, wrong, wrong
319703 by: Matijn Woudt

Re: memory allocation error
319704 by: Carol Peck

error_handler : unique caller ID ?
319705 by: B. Aerts
319706 by: Robert Williams
319707 by: B. Aerts

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On Tue, Nov 13, 2012 at 5:11 AM, Kanishka kanishkani...@gmail.com wrote:

 if we use a date after 19 January 2038, we can not use 'strtotime' to get
 timestamp.
 http://en.wikipedia.org/wiki/Year_2038_problem


Only if you're running 32bit OS. If you're running 64bit OS with 64bit PHP
you can represent about 580 billion years...

- Matijn
---End Message---
---BeginMessage---



On 11/13/2012 6:29 AM, Matijn Woudt wrote:




On Tue, Nov 13, 2012 at 12:23 AM, Carol Peck carolap...@gmail.com 
mailto:carolap...@gmail.com wrote:



On 11/12/2012 11:51 AM, Matijn Woudt wrote:


On Mon, Nov 12, 2012 at 3:17 PM, Carol Peck carolap...@gmail.com
mailto:carolap...@gmail.com wrote:

Sebastian,
Yes, I do , but this particular error never gets into my
custom handler.
I have also set it so that fatal errors fall through, and
that doesn't seem to make any difference (again, probably
because it never gets there).

Carol


Can you post the code of the error handler? I guess the bug is
there. Bugs like these are mostly because of recursion errors or
something. (Don't know if it's possible, but an error inside the
error handler?)
Fatal errors will btw always fall through, you can't catch fatal
errors. You should, for testing, turn off your custom error
handler and see what it does.

- Matijn

Ps. Please bottom-post on this mailing list.

Here is the error class (I hope Im posting the code the right
way).  I will turn this off for a while.
It's main purpose is to format the message before logging.  I do
know that things are getting logged properly.

Thanks again.


Snip some code

Your hosting is using SuPHP which most likely causes these problems. 
You have two options:

1) Get a better host, or even better, get a dedicated server.
2) Increase your memory limit, even though your script doesn't really 
reaches that limit, it seems that SuPHP somehow messes that up. Read 
more at [1].


- Matijn

[1] http://forum.inmotionhosting.com/viewtopic.php?t=3147

Matijn,
Thanks so much, I had found that post but thought it was related to the 
SilverStripe CMS they were referencing.  I've been coming to the same 
conclusion about the host.

Cheers,
Carol

---End Message---
---BeginMessage---

Dear list,

a penny for your thoughts on the following problem.

Does anyone have an idea how to find a unique caller ID for a 
user-defined error handler ?


The goal is to get a cached error messages tree where the following 
snippet would yield an array as below it:


// start-of-snippet

function Outer($a)
{
   trigger_error('entering Outer');
   $a=Inner($a) ;
   trigger_error('leaving Outer') ;
}

function Inner($x)
{
   trigger_error('entering Inner');
   return(2*$x) ;
}

trigger_error('Here we go ');
$b = 1 ;
$b = Outer($b) ;
trigger_error('End result is $b');


// end-of-snippet

Output:

Array(
[0] = 'Here we go'
['Outer(unique_ID_01)'] = Array(
   [0] = 'entering Outer' ;
   ['Inner(unique_ID_02)'] = Array(
  [0] = 'entering Inner' ;
   )
   [1] = 'leaving Outer' ;
   )
[1] = 'End result is 2'
)

I've considered the 'args' option in debug_backtrace(), but that fails 
for referenced arguments.


Having read access to a variable's address (like a C-pointer) would be 
perfect - but Google tells me you can't in PHP.


Any other idea's ?

Regards,

Bert
---End Message---
---BeginMessage---
On 11/13/12 11:20, B. Aerts ba_ae...@yahoo.com wrote:


Having read access to a variable's address (like a C-pointer) would be
perfect - but Google tells me you can't in PHP.

If you can restrict yourself to objects for the passed variables, you can
use spl_object_hash(). It does exactly what you need, but it only works
with objects. AFAIK, there's no equivalent for scalars or arrays.

http://php.net/manual/en/function.spl-object-hash.php


Regards,
Bob

--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/







Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only 

Re: [PHP] error_handler : unique caller ID ?

2012-11-14 Thread B. Aerts

On 13/11/12 20:04, Robert Williams wrote:

On 11/13/12 11:20, B. Aerts ba_ae...@yahoo.com wrote:



Having read access to a variable's address (like a C-pointer) would be
perfect - but Google tells me you can't in PHP.


If you can restrict yourself to objects for the passed variables, you can
use spl_object_hash(). It does exactly what you need, but it only works
with objects. AFAIK, there's no equivalent for scalars or arrays.

http://php.net/manual/en/function.spl-object-hash.php


Regards,
Bob

--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/



Hello Bob,

thanks for the tip - indeed it does exactly what I need.
Unfortunately, I need to keep scalars/arrays in the frame too.

But thinking along your line, do you know of a function that does a 
similar thing to the function call itsself ?


( as functions get stacked, called recursive or through callback 
mechanisms, there must be a similar allocation table/mechanism as for 
variables/objects)


Regards,

Bert


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Pear Mail - Trap for errors?

2012-11-14 Thread Rick Dwyer
Hello all.

I have some Pear Mail code composing an email and sending it to an external 
smtp server for sending. 

The issue is determining whether that external server actually accepted the 
mail or not.  In the IF(PEAR… code below, it will return success even if I 
leave the $to value empty.  However, if I remove the smtp username or password, 
it will return an error indicating it could not reach the remote server.  So 
the Pear::IsError function seems to only reflect if the intended server was 
accessible… and not if the intended server accepted the outgoing email for 
delivery.

Anyone have experience with the scenario below… specifically with determining 
if the smtp server accepted the mail for delivery?

Thanks for any info.

--Rick






 require_once Mail.php;
 
 $from = f...@address.com;
 $to = t...@address.com;
 $subject = Hello!;
 $body = Hello!;
 
 $host = mail.host.net;
 $username = myuser;
 $password = mypass;
 
 $headers = array ('From' = $from,'To' = $to,'Subject' = $subject);
 $smtp = Mail::factory('smtp',array ('host' = $host,'auth' = true,'username' 
= $username,'password' = $password));
 
 $mail = $smtp-send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo(p . $mail-getMessage() . /p);
  } else {
   echo(pMessage successfully sent!/p);
  }
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pear Mail - Trap for errors?

2012-11-14 Thread tamouse mailing lists
On Wed, Nov 14, 2012 at 7:19 PM, Rick Dwyer rpdw...@earthlink.net wrote:
 Hello all.

 I have some Pear Mail code composing an email and sending it to an external 
 smtp server for sending.

 The issue is determining whether that external server actually accepted the 
 mail or not.  In the IF(PEAR… code below, it will return success even if I 
 leave the $to value empty.  However, if I remove the smtp username or 
 password, it will return an error indicating it could not reach the remote 
 server.  So the Pear::IsError function seems to only reflect if the intended 
 server was accessible… and not if the intended server accepted the outgoing 
 email for delivery.

 Anyone have experience with the scenario below… specifically with determining 
 if the smtp server accepted the mail for delivery?

 Thanks for any info.

 --Rick

  require_once Mail.php;

  $from = f...@address.com;
  $to = t...@address.com;
  $subject = Hello!;
  $body = Hello!;

  $host = mail.host.net;
  $username = myuser;
  $password = mypass;

  $headers = array ('From' = $from,'To' = $to,'Subject' = $subject);
  $smtp = Mail::factory('smtp',array ('host' = $host,'auth' = 
 true,'username' = $username,'password' = $password));

I'd suggest putting a check here to see if $smtp is a PEAR::Error
object as well:

if (PEAR::isError($smtp)) {
  echo (p . $smtp-getMessage() . /p);
  // die or return or skip the next part, whatever
} else {

  $mail = $smtp-send($to, $headers, $body);

  if (PEAR::isError($mail)) {
echo(p . $mail-getMessage() . /p);
   } else {
echo(pMessage successfully sent!/p);
   }

}


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php