php-general Digest 15 Aug 2012 12:09:45 -0000 Issue 7923

Topics (messages 318701 through 318705):

Re: Reading class variable value always returns NULL
        318701 by: Reto Kaiser

Re: PHP session variables
        318702 by: tamouse mailing lists

Two ways to obtain an object property
        318703 by: phplist
        318704 by: Sebastian Krebs

Re: How to catch an exception using SoapClient.
        318705 by: Ellis Antaya

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


----------------------------------------------------------------------
--- Begin Message ---
Hey,

We have:
error_reporting((E_ALL | E_STRICT) & ~(E_NOTICE | E_USER_NOTICE));

Displaying errors is disabled:
display_errors = Off

We have a custom error handler which logs all errors to a file.
In this file we receive byeffect errors, like that the second argument
to "array_key_exists" should be array, but is NULL. When we further
debug the reason is that the second argument is an instance variable,
and all instance variables are NULL.
We're pretty sure this is a software bug, since it only happens from
time to time, and already happens in the first line of the php script,
when none of our application code was loaded.
For example:

<?php
class A{}
$a = new A();
$a->foo = 1;
if ($a->foo === null) {
 throw new Exception("strange");
}

will throw an exception.

Since it only happens from time to time, it is really hard to debug.
We're now trying to reproduce in a virtual machine environment, while
replaying the actual requests that our webserver received. When we're
just simulating random load on the web server it doesn't happen. So it
must have something to do with certain requests, and they must have
some strange byeffect on php, or mod_php or something related.

Any input welcome!

Thanks,
 Reto

On Tue, Aug 14, 2012 at 11:11 PM, Jim Lucas <li...@cmsws.com> wrote:
> On 08/12/2012 05:32 AM, Reto Kaiser wrote:
>>
>> Hi,
>>
>> So I have this strange situation where I assign a classvariable a
>> value, but when I read the value it is NULL.
>>
>> Does anyone have an idea what could cause this, or how to further debug?
>>
>> Thanks,
>>   Reto
>>
>
> What is your error reporting set to?
>
> Do you have display errors turned on?
>
> Are you saving your errors to a log file?
>
> --
> Jim Lucas
>
> http://www.cmsws.com/
> http://www.cmsws.com/examples/

--- End Message ---
--- Begin Message ---
On Aug 14, 2012 1:36 AM, "tamouse mailing lists" <tamouse.li...@gmail.com>
wrote:
>
>
> On Aug 13, 2012 8:01 AM, "Robert Cummings" <rob...@interjinn.com> wrote:
> >
> > On 12-08-10 04:42 PM, Tedd Sperling wrote:
> >>
> >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin <sertce...@itu.edu.tr>
wrote:
> >>
> >>> Hi. My question will maybe out of topic, I'm sorry.
> >>> How can you know that one way will be much slower than other one? I
mean, how can I learn which function is faster before I test it?
> >>
> >>
> >> Ege:
> >>
> >> No your question is on topic.
> >>
> >> This question should be asked on the list, so I'll present Q:A instead
of answering privately
> >>
> >> http://www.webbytedd.com/b/timed1/
> >>
> >> The code is there -- if you have questions, please post them to the
list.
> >
> >
> > Ted,
> >
> > Please see the current signature for microtime():
> >
> >     mixed microtime ([ bool $get_as_float = false ] )
> >
> > The optional paramter was added in PHP 5.0.0. I think it's safe to
update your habits :)
> >
> > Cheers,
> > Rob.
> > --
> > E-Mail Disclaimer: Information contained in this message and any
> > attached documents is considered confidential and legally protected.
> > This message is intended solely for the addressee(s). Disclosure,
> > copying, and distribution are prohibited unless authorized.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> What are the timing values if you do something besides session start with
no close?

Just to clarify, since at least 4.3.x subsequent calls session_start raise
an E_NOTICE and are ignored, so you're first call is generating almost all
the time.

--- End Message ---
--- Begin Message --- This relates to a minor dilemma I come across from time and time, and I'm looking for advice on pros and cons and best practice. Last night I encountered it again.

Within a site I have a User object, and within page code would like to have
if ($crntUser->isASubscriber) {...}

There seems to be two ways to handle this:

I can have a User object method "getSubscriberStatus()" which sets $this->isASubscriber. But to use this I would have to run the method just before the if statement.

Or I could have a method "isASubscriber()" which returns the result, meaning the if statement should be
if ($crntUser->isASubscriber()) {...}

While this is last night's specific example, I seem to face the method-setting-variable or the method-returning-result-directly decision quite often.

Is either of these approaches preferable, or does it simply not matter?

Thanks

Roddie Grant

--- End Message ---
--- Begin Message ---
Hi,

2012/8/15 phplist <phpl...@myword.co.uk>

> This relates to a minor dilemma I come across from time and time, and I'm
> looking for advice on pros and cons and best practice. Last night I
> encountered it again.
>
> Within a site I have a User object, and within page code would like to have
> if ($crntUser->isASubscriber) {...}
>
> There seems to be two ways to handle this:
>
> I can have a User object method "getSubscriberStatus()" which sets
> $this->isASubscriber. But to use this I would have to run the method just
> before the if statement.
>
> Or I could have a method "isASubscriber()" which returns the result,
> meaning the if statement should be
> if ($crntUser->isASubscriber()) {...}
>

or you just set User::$isASubscriber before.
or you can utilise __get()

I don't really get the problem. You can for example set the property right
after instanciation, or during instanciation (constructor).

$this->isASubscriber = !empty($subscriptions); // or something like that

Regards,
Sebastian


>
> While this is last night's specific example, I seem to face the
> method-setting-variable or the method-returning-result-**directly
> decision quite often.
>
> Is either of these approaches preferable, or does it simply not matter?
>
> Thanks
>
> Roddie Grant
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
like any other exception ... using a try catch block ;)

Ellis
1100101000111101
" Unfortunately, no one can be told what The Matrix is.  You have to see it
for yourself. "
twitter.com/floverdevel
facebook.com/ellis.antaya
google.com/profiles/ellis.antaya
linkedin.com/in/ellisantaya



On Mon, Aug 6, 2012 at 10:56 PM, James Newman <
james.new...@primalmedia.co.nz> wrote:

> I was wondering how I'd catch an exception using SoapClient.
>
>
>
> $data = array(
> 'Particular'=>'Payment for stuff',
>  'Email' =>'e <phi...@newman.net.nz>mail address',
>  'CardNumber'=>'0000000000000000,
> 'CardType' =>'MC',
>  'CardExpiry'=>'0423',
> 'CardHolderName'=>'James Newman',
>  'CardCSC' =>'111',
> 'StoreCard' =>'true'
>  );
>  $vars = array(
>  'trace' => 1,
> 'exceptions' => true,
>         'cache_wsdl' => WSDL_CACHE_NONE,
>         'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
>  $client = new SoapClient("http://XMLSERVICEURLws/paymentws.asmx?WSDL";,
> $vars);
>
> #$out = $client->ListCards($text);
>  #$this->_result = $client->ProcessPurchase($data);
> $this->_result = $client->ProcessAuthorise($data);
>  #var_dump($client->__getLastRequestHeaders());
> #var_dump($client->__getTypes());
>  print_r($this->_result);
>

--- End Message ---

Reply via email to