Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3094

Re: what does mean this?

From sheldonlg <sheldonlg@thevillages.net>
Newsgroups comp.lang.php
Subject Re: what does mean this?
Date 2011-09-07 10:37 -0400
Organization A noiseless patient Spider
Message-ID <j4803l$k10$1@dont-email.me> (permalink)
References <4e668493$0$15662$4fafbaef@reader2.news.tin.it> <up1d67t0973bdmlmne3fml018fararr39k@mfesser.de> <4e675e6d$0$15658$4fafbaef@reader2.news.tin.it>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

what does mean this? rataplanbumbum <rataplanbumbum> - 2011-09-06 22:37 +0200
  Re: what does mean this? Jerry Stuckle <jstucklex@attglobal.net> - 2011-09-06 16:54 -0400
  Re: what does mean this? Michael Fesser <netizen@gmx.de> - 2011-09-06 22:59 +0200
    Re: what does mean this? rataplanbumbum <rataplanbumbum> - 2011-09-07 14:07 +0200
      Re: what does mean this? sheldonlg <sheldonlg@thevillages.net> - 2011-09-07 10:37 -0400

csiph-web