what does mean this? [message #175333] |
Tue, 06 September 2011 20:37 |
rataplanbumbum
Messages: 13 Registered: June 2011
Karma: 0
|
Junior Member |
|
|
In a script I have a statement:
$cartID = $cart->cartID = $cart->generate_cart_id();
can someone explain what does this mean?
Thanks!
|
|
|
Re: what does mean this? [message #175334 is a reply to message #175333] |
Tue, 06 September 2011 20:54 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/6/2011 4:37 PM, rataplanbumbum wrote:
> In a script I have a statement:
>
> $cartID = $cart->cartID = $cart->generate_cart_id();
>
>
> can someone explain what does this mean?
>
> Thanks!
It calls the function generate_cart_id() in the object $cart.
It takes the results of that function and places it in the cardID member
of the object $cart.
It then takes the result and places it in the variable $cartID.
It is equivalent to:
$cart->cartID = $cart->generate_cart_id();
$cartID = $cart->cartID;
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: what does mean this? [message #175335 is a reply to message #175333] |
Tue, 06 September 2011 20:59 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
.oO(rataplanbumbum)
> In a script I have a statement:
>
> $cartID = $cart->cartID = $cart->generate_cart_id();
>
>
> can someone explain what does this mean?
$cart is an object. Its method generate_cart_id() returns some value,
which is assigned to both the variable $cartID and the object property
$cart->cartID.
A more complex way to code this would be:
$result = $cart->generate_cart_id();
$cart->cartID = $result;
$cartID = $result;
What's ugly about this is that the same value is stored in an object
property and in a variable. Without knowing the context this doesn't
look good.
Micha
--
http://mfesser.de/blickwinkel
|
|
|
Re: what does mean this? [message #175339 is a reply to message #175335] |
Wed, 07 September 2011 12:07 |
rataplanbumbum
Messages: 13 Registered: June 2011
Karma: 0
|
Junior Member |
|
|
Il 06/09/2011 22:59, Michael Fesser ha scritto:
> .oO(rataplanbumbum)
>
>> In a script I have a statement:
>>
>> $cartID = $cart->cartID = $cart->generate_cart_id();
>>
>>
>> can someone explain what does this mean?
>
> $cart is an object. Its method generate_cart_id() returns some value,
> which is assigned to both the variable $cartID and the object property
> $cart->cartID.
>
> A more complex way to code this would be:
>
> $result = $cart->generate_cart_id();
> $cart->cartID = $result;
> $cartID = $result;
>
> What's ugly about this is that the same value is stored in an object
> property and in a variable. Without knowing the context this doesn't
> look good.
>
> Micha
>
tnks
|
|
|
Re: what does mean this? [message #175340 is a reply to message #175339] |
Wed, 07 September 2011 14:37 |
sheldonlg
Messages: 166 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/7/2011 8:07 AM, rataplanbumbum wrote:
> Il 06/09/2011 22:59, Michael Fesser ha scritto:
>> .oO(rataplanbumbum)
>>
>>> In a script I have a statement:
>>>
>>> $cartID = $cart->cartID = $cart->generate_cart_id();
>>>
>>>
>>> can someone explain what does this mean?
>>
>> $cart is an object. Its method generate_cart_id() returns some value,
>> which is assigned to both the variable $cartID and the object property
>> $cart->cartID.
>>
>> A more complex way to code this would be:
>>
>> $result = $cart->generate_cart_id();
>> $cart->cartID = $result;
>> $cartID = $result;
>>
>> What's ugly about this is that the same value is stored in an object
>> property and in a variable. Without knowing the context this doesn't
>> look good.
>>
>> Micha
>>
>
> tnks
I would write this code as:
$cart->generate_cart_id();
$cartID = $cart->getCartId();
(where generate_cart_id() would also store a private class variable,
$cardID, as part of the generation)
--
Shelly
|
|
|