Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If I can have honesty, it's easier to overlook mistakes. -- Kirk, "Space Seed", stardate 3141.9


devel / comp.lang.php / Re: ArrayObject vs array

SubjectAuthor
* ArrayObject vs arrayalex
`* Re: ArrayObject vs arrayJerry Stuckle
 `* Re: ArrayObject vs arrayalex
  `* Re: ArrayObject vs arrayJ.O. Aho
   `* Re: ArrayObject vs arrayalex
    `* Re: ArrayObject vs arrayJerry Stuckle
     `* Re: ArrayObject vs arrayalex
      `* Re: ArrayObject vs arrayJ.O. Aho
       `* Re: ArrayObject vs arrayalex
        +- Re: ArrayObject vs arrayJ.O. Aho
        `- Re: ArrayObject vs arrayArno Welzel

1
ArrayObject vs array

<sde1e5$p89$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=299&group=comp.lang.php#299

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!P5/71iTN5k21vE+LdpDjUA.user.46.165.242.91.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: ArrayObject vs array
Date: Fri, 23 Jul 2021 11:16:28 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sde1e5$p89$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="25865"; posting-host="P5/71iTN5k21vE+LdpDjUA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Content-Language: it-IT
X-Mozilla-News-Host: news://news.aioe.org:119
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Fri, 23 Jul 2021 09:16 UTC

class C implements ArrayAccess, Countable, IteratorAggregate, Serializable {

private $container = ['a', 'b'];

public function offsetSet($offset, $value) {
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}

public function offsetExists($offset) {
return isset($this->container[$offset]);
}

public function offsetUnset($offset) {
unset($this->container[$offset]);
}

public function offsetGet($offset) {
return isset($this->container[$offset]) ?
$this->container[$offset] : null;
}

public function count() {
return count($this->container);
}

public function getIterator() {
return new ArrayIterator($this->container);
}

public function serialize() {
return serialize($this->container);
}

public function unserialize($data) {
$this->container = unserialize($data);
}

public function getData() {
return $this->container;
}

}

print_r(
(array) new ArrayObject(['a', 'b'])
);
print_r(
(array) new C
);

Output:

Array
( [0] => a
[1] => b
) Array
( [Ccontainer] => Array
(
[0] => a
[1] => b
)

)

Because the result is not the same?

Re: ArrayObject vs array

<sdeuru$3h5$1@jstuckle.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=301&group=comp.lang.php#301

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: jstucklex@attglobal.net (Jerry Stuckle)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Fri, 23 Jul 2021 13:39:01 -0400
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <sdeuru$3h5$1@jstuckle.eternal-september.org>
References: <sde1e5$p89$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 23 Jul 2021 17:39:11 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="4e9620acd95a0835d017f42822d00c47";
logging-data="3621"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lo8BRjcAS1ViOQZcVwUkz47nB1X+wcrI="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:sMJr1wJ8NnLBTFTJk2cL4WzJP2U=
In-Reply-To: <sde1e5$p89$1@gioia.aioe.org>
Content-Language: en-US
 by: Jerry Stuckle - Fri, 23 Jul 2021 17:39 UTC

On 7/23/2021 5:16 AM, alex wrote:
> class C implements ArrayAccess, Countable, IteratorAggregate,
> Serializable {
>
>     private $container = ['a', 'b'];
>
>     public function offsetSet($offset, $value) {
>         if (is_null($offset)) {
>             $this->container[] = $value;
>         } else {
>             $this->container[$offset] = $value;
>         }
>     }
>
>     public function offsetExists($offset) {
>         return isset($this->container[$offset]);
>     }
>
>     public function offsetUnset($offset) {
>         unset($this->container[$offset]);
>     }
>
>     public function offsetGet($offset) {
>         return isset($this->container[$offset]) ?
> $this->container[$offset] : null;
>     }
>
>     public function count() {
>         return count($this->container);
>     }
>
>     public function getIterator() {
>         return new ArrayIterator($this->container);
>     }
>
>     public function serialize() {
>         return serialize($this->container);
>     }
>
>     public function unserialize($data) {
>         $this->container = unserialize($data);
>     }
>
>     public function getData() {
>         return $this->container;
>     }
>
> }
>
> print_r(
>         (array) new ArrayObject(['a', 'b'])
> );
> print_r(
>         (array) new C
> );
>
> Output:
>
> Array
> (
>     [0] => a
>     [1] => b
> )
> Array
> (
>     [Ccontainer] => Array
>         (
>             [0] => a
>             [1] => b
>         )
>
> )
>
> Because the result is not the same?

An object is not the same as a basic type. A basic type holds one or
more values. An object can also have methods to operate on those
values. The two are not compatible.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Re: ArrayObject vs array

<sdgbps$18kp$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=303&group=comp.lang.php#303

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!XeyDHBeMmIt7nb5KMmJyiQ.user.46.165.242.91.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Sat, 24 Jul 2021 08:26:04 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sdgbps$18kp$1@gioia.aioe.org>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="41625"; posting-host="XeyDHBeMmIt7nb5KMmJyiQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: it-IT
 by: alex - Sat, 24 Jul 2021 06:26 UTC

Il 23/07/21 19:39, Jerry Stuckle ha scritto:
> On 7/23/2021 5:16 AM, alex wrote:
>> class C implements ArrayAccess, Countable, IteratorAggregate,
>> Serializable {
>>
>>      private $container = ['a', 'b'];
>>
>>      public function offsetSet($offset, $value) {
>>          if (is_null($offset)) {
>>              $this->container[] = $value;
>>          } else {
>>              $this->container[$offset] = $value;
>>          }
>>      }
>>
>>      public function offsetExists($offset) {
>>          return isset($this->container[$offset]);
>>      }
>>
>>      public function offsetUnset($offset) {
>>          unset($this->container[$offset]);
>>      }
>>
>>      public function offsetGet($offset) {
>>          return isset($this->container[$offset]) ?
>> $this->container[$offset] : null;
>>      }
>>
>>      public function count() {
>>          return count($this->container);
>>      }
>>
>>      public function getIterator() {
>>          return new ArrayIterator($this->container);
>>      }
>>
>>      public function serialize() {
>>          return serialize($this->container);
>>      }
>>
>>      public function unserialize($data) {
>>          $this->container = unserialize($data);
>>      }
>>
>>      public function getData() {
>>          return $this->container;
>>      }
>>
>> }
>>
>> print_r(
>>          (array) new ArrayObject(['a', 'b'])
>> );
>> print_r(
>>          (array) new C
>> );
>>
>> Output:
>>
>> Array
>> (
>>      [0] => a
>>      [1] => b
>> )
>> Array
>> (
>>      [Ccontainer] => Array
>>          (
>>              [0] => a
>>              [1] => b
>>          )
>>
>> )
>>
>> Because the result is not the same?
>
> An object is not the same as a basic type.  A basic type holds one or
> more values.  An object can also have methods to operate on those
> values.  The two are not compatible.
>

Could you tell me what these methods are?

Re: ArrayObject vs array

<im277qF7fbjU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=311&group=comp.lang.php#311

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Sat, 24 Jul 2021 12:10:02 +0200
Lines: 104
Message-ID: <im277qF7fbjU1@mid.individual.net>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net EyQRujA+IXqDSpXT2fqPIgaZ/msm6326HPKHzow1eBaC2XDL9A
Cancel-Lock: sha1:nOz0YArXQKcF0QVobiM1rjh0BTg=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <sdgbps$18kp$1@gioia.aioe.org>
Content-Language: en-US-large
 by: J.O. Aho - Sat, 24 Jul 2021 10:10 UTC

On 24/07/2021 08.26, alex wrote:
> Il 23/07/21 19:39, Jerry Stuckle ha scritto:
>> On 7/23/2021 5:16 AM, alex wrote:
>>> class C implements ArrayAccess, Countable, IteratorAggregate,
>>> Serializable {
>>>
>>>      private $container = ['a', 'b'];
>>>
>>>      public function offsetSet($offset, $value) {
>>>          if (is_null($offset)) {
>>>              $this->container[] = $value;
>>>          } else {
>>>              $this->container[$offset] = $value;
>>>          }
>>>      }
>>>
>>>      public function offsetExists($offset) {
>>>          return isset($this->container[$offset]);
>>>      }
>>>
>>>      public function offsetUnset($offset) {
>>>          unset($this->container[$offset]);
>>>      }
>>>
>>>      public function offsetGet($offset) {
>>>          return isset($this->container[$offset]) ?
>>> $this->container[$offset] : null;
>>>      }
>>>
>>>      public function count() {
>>>          return count($this->container);
>>>      }
>>>
>>>      public function getIterator() {
>>>          return new ArrayIterator($this->container);
>>>      }
>>>
>>>      public function serialize() {
>>>          return serialize($this->container);
>>>      }
>>>
>>>      public function unserialize($data) {
>>>          $this->container = unserialize($data);
>>>      }
>>>
>>>      public function getData() {
>>>          return $this->container;
>>>      }
>>>
>>> }
>>>
>>> print_r(
>>>          (array) new ArrayObject(['a', 'b'])
>>> );
>>> print_r(
>>>          (array) new C
>>> );
>>>
>>> Output:
>>>
>>> Array
>>> (
>>>      [0] => a
>>>      [1] => b
>>> )
>>> Array
>>> (
>>>      [Ccontainer] => Array
>>>          (
>>>              [0] => a
>>>              [1] => b
>>>          )
>>>
>>> )
>>>
>>> Because the result is not the same?
>>
>> An object is not the same as a basic type.  A basic type holds one or
>> more values.  An object can also have methods to operate on those
>> values.  The two are not compatible.
>>
>
> Could you tell me what these methods are?

The object can be of any type, so the whole depends on the class definition.

for example:
class myclass {
public $array = Array();
public function getFirst() {
if(sizeof($this->array) == 0)
{
return null;
}
return $this->array[1];
}
}

this has the method getFirst.

--

//Aho

Re: ArrayObject vs array

<sdgs5f$1suj$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=312&group=comp.lang.php#312

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!XeyDHBeMmIt7nb5KMmJyiQ.user.46.165.242.91.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Sat, 24 Jul 2021 13:05:19 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sdgs5f$1suj$1@gioia.aioe.org>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="62419"; posting-host="XeyDHBeMmIt7nb5KMmJyiQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Sat, 24 Jul 2021 11:05 UTC

Il 24/07/21 12:10, J.O. Aho ha scritto:
> On 24/07/2021 08.26, alex wrote:
>> Il 23/07/21 19:39, Jerry Stuckle ha scritto:
>>> On 7/23/2021 5:16 AM, alex wrote:
>>>> class C implements ArrayAccess, Countable, IteratorAggregate,
>>>> Serializable {
>>>>
>>>>      private $container = ['a', 'b'];
>>>>
>>>>      public function offsetSet($offset, $value) {
>>>>          if (is_null($offset)) {
>>>>              $this->container[] = $value;
>>>>          } else {
>>>>              $this->container[$offset] = $value;
>>>>          }
>>>>      }
>>>>
>>>>      public function offsetExists($offset) {
>>>>          return isset($this->container[$offset]);
>>>>      }
>>>>
>>>>      public function offsetUnset($offset) {
>>>>          unset($this->container[$offset]);
>>>>      }
>>>>
>>>>      public function offsetGet($offset) {
>>>>          return isset($this->container[$offset]) ?
>>>> $this->container[$offset] : null;
>>>>      }
>>>>
>>>>      public function count() {
>>>>          return count($this->container);
>>>>      }
>>>>
>>>>      public function getIterator() {
>>>>          return new ArrayIterator($this->container);
>>>>      }
>>>>
>>>>      public function serialize() {
>>>>          return serialize($this->container);
>>>>      }
>>>>
>>>>      public function unserialize($data) {
>>>>          $this->container = unserialize($data);
>>>>      }
>>>>
>>>>      public function getData() {
>>>>          return $this->container;
>>>>      }
>>>>
>>>> }
>>>>
>>>> print_r(
>>>>          (array) new ArrayObject(['a', 'b'])
>>>> );
>>>> print_r(
>>>>          (array) new C
>>>> );
>>>>
>>>> Output:
>>>>
>>>> Array
>>>> (
>>>>      [0] => a
>>>>      [1] => b
>>>> )
>>>> Array
>>>> (
>>>>      [Ccontainer] => Array
>>>>          (
>>>>              [0] => a
>>>>              [1] => b
>>>>          )
>>>>
>>>> )
>>>>
>>>> Because the result is not the same?
>>>
>>> An object is not the same as a basic type.  A basic type holds one or
>>> more values.  An object can also have methods to operate on those
>>> values.  The two are not compatible.
>>>
>>
>> Could you tell me what these methods are?
>
> The object can be of any type, so the whole depends on the class
> definition.
>
> for example:
> class myclass {
>     public $array = Array();
>     public function getFirst() {
>         if(sizeof($this->array) == 0)
>         {
>             return null;
>         }
>         return $this->array[1];
>     }
> }
>
> this has the method getFirst.
>

???????
So what?

Re: ArrayObject vs array

<sdhgno$tt9$1@jstuckle.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=313&group=comp.lang.php#313

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: jstucklex@attglobal.net (Jerry Stuckle)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Sat, 24 Jul 2021 12:56:13 -0400
Organization: A noiseless patient Spider
Lines: 118
Message-ID: <sdhgno$tt9$1@jstuckle.eternal-september.org>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net> <sdgs5f$1suj$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 24 Jul 2021 16:56:25 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="bf4146999d4c36d48c75091f2a1333ee";
logging-data="30633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nu3zNC8yK4HvkIIQ6jLHPA+1U5y3mLFI="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:mcYLRpFw1ZMtyW4rkc4oUAiClQ0=
In-Reply-To: <sdgs5f$1suj$1@gioia.aioe.org>
Content-Language: en-US
 by: Jerry Stuckle - Sat, 24 Jul 2021 16:56 UTC

On 7/24/2021 7:05 AM, alex wrote:
> Il 24/07/21 12:10, J.O. Aho ha scritto:
>> On 24/07/2021 08.26, alex wrote:
>>> Il 23/07/21 19:39, Jerry Stuckle ha scritto:
>>>> On 7/23/2021 5:16 AM, alex wrote:
>>>>> class C implements ArrayAccess, Countable, IteratorAggregate,
>>>>> Serializable {
>>>>>
>>>>>      private $container = ['a', 'b'];
>>>>>
>>>>>      public function offsetSet($offset, $value) {
>>>>>          if (is_null($offset)) {
>>>>>              $this->container[] = $value;
>>>>>          } else {
>>>>>              $this->container[$offset] = $value;
>>>>>          }
>>>>>      }
>>>>>
>>>>>      public function offsetExists($offset) {
>>>>>          return isset($this->container[$offset]);
>>>>>      }
>>>>>
>>>>>      public function offsetUnset($offset) {
>>>>>          unset($this->container[$offset]);
>>>>>      }
>>>>>
>>>>>      public function offsetGet($offset) {
>>>>>          return isset($this->container[$offset]) ?
>>>>> $this->container[$offset] : null;
>>>>>      }
>>>>>
>>>>>      public function count() {
>>>>>          return count($this->container);
>>>>>      }
>>>>>
>>>>>      public function getIterator() {
>>>>>          return new ArrayIterator($this->container);
>>>>>      }
>>>>>
>>>>>      public function serialize() {
>>>>>          return serialize($this->container);
>>>>>      }
>>>>>
>>>>>      public function unserialize($data) {
>>>>>          $this->container = unserialize($data);
>>>>>      }
>>>>>
>>>>>      public function getData() {
>>>>>          return $this->container;
>>>>>      }
>>>>>
>>>>> }
>>>>>
>>>>> print_r(
>>>>>          (array) new ArrayObject(['a', 'b'])
>>>>> );
>>>>> print_r(
>>>>>          (array) new C
>>>>> );
>>>>>
>>>>> Output:
>>>>>
>>>>> Array
>>>>> (
>>>>>      [0] => a
>>>>>      [1] => b
>>>>> )
>>>>> Array
>>>>> (
>>>>>      [Ccontainer] => Array
>>>>>          (
>>>>>              [0] => a
>>>>>              [1] => b
>>>>>          )
>>>>>
>>>>> )
>>>>>
>>>>> Because the result is not the same?
>>>>
>>>> An object is not the same as a basic type.  A basic type holds one
>>>> or more values.  An object can also have methods to operate on those
>>>> values.  The two are not compatible.
>>>>
>>>
>>> Could you tell me what these methods are?
>>
>> The object can be of any type, so the whole depends on the class
>> definition.
>>
>> for example:
>> class myclass {
>>      public $array = Array();
>>      public function getFirst() {
>>          if(sizeof($this->array) == 0)
>>          {
>>              return null;
>>          }
>>          return $this->array[1];
>>      }
>> }
>>
>> this has the method getFirst.
>>
>
> ???????
> So what?

It means that the ArrayObject is a built-in type allows an object to
function as an array, as the PHP doc says. Your user-defined object
contains an array but does not function as an array, as the output from
print_r() shows.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Re: ArrayObject vs array

<sdj9us$o4p$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=315&group=comp.lang.php#315

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!XeyDHBeMmIt7nb5KMmJyiQ.user.46.165.242.91.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Sun, 25 Jul 2021 11:13:00 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sdj9us$o4p$1@gioia.aioe.org>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net> <sdgs5f$1suj$1@gioia.aioe.org>
<sdhgno$tt9$1@jstuckle.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="24729"; posting-host="XeyDHBeMmIt7nb5KMmJyiQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: it-IT
 by: alex - Sun, 25 Jul 2021 09:13 UTC

Il 24/07/21 18:56, Jerry Stuckle ha scritto:
> On 7/24/2021 7:05 AM, alex wrote:
>> Il 24/07/21 12:10, J.O. Aho ha scritto:
>>> On 24/07/2021 08.26, alex wrote:
>>>> Il 23/07/21 19:39, Jerry Stuckle ha scritto:
>>>>> On 7/23/2021 5:16 AM, alex wrote:
>>>>>> class C implements ArrayAccess, Countable, IteratorAggregate,
>>>>>> Serializable {
>>>>>>
>>>>>>      private $container = ['a', 'b'];
>>>>>>
>>>>>>      public function offsetSet($offset, $value) {
>>>>>>          if (is_null($offset)) {
>>>>>>              $this->container[] = $value;
>>>>>>          } else {
>>>>>>              $this->container[$offset] = $value;
>>>>>>          }
>>>>>>      }
>>>>>>
>>>>>>      public function offsetExists($offset) {
>>>>>>          return isset($this->container[$offset]);
>>>>>>      }
>>>>>>
>>>>>>      public function offsetUnset($offset) {
>>>>>>          unset($this->container[$offset]);
>>>>>>      }
>>>>>>
>>>>>>      public function offsetGet($offset) {
>>>>>>          return isset($this->container[$offset]) ?
>>>>>> $this->container[$offset] : null;
>>>>>>      }
>>>>>>
>>>>>>      public function count() {
>>>>>>          return count($this->container);
>>>>>>      }
>>>>>>
>>>>>>      public function getIterator() {
>>>>>>          return new ArrayIterator($this->container);
>>>>>>      }
>>>>>>
>>>>>>      public function serialize() {
>>>>>>          return serialize($this->container);
>>>>>>      }
>>>>>>
>>>>>>      public function unserialize($data) {
>>>>>>          $this->container = unserialize($data);
>>>>>>      }
>>>>>>
>>>>>>      public function getData() {
>>>>>>          return $this->container;
>>>>>>      }
>>>>>>
>>>>>> }
>>>>>>
>>>>>> print_r(
>>>>>>          (array) new ArrayObject(['a', 'b'])
>>>>>> );
>>>>>> print_r(
>>>>>>          (array) new C
>>>>>> );
>>>>>>
>>>>>> Output:
>>>>>>
>>>>>> Array
>>>>>> (
>>>>>>      [0] => a
>>>>>>      [1] => b
>>>>>> )
>>>>>> Array
>>>>>> (
>>>>>>      [Ccontainer] => Array
>>>>>>          (
>>>>>>              [0] => a
>>>>>>              [1] => b
>>>>>>          )
>>>>>>
>>>>>> )
>>>>>>
>>>>>> Because the result is not the same?
>>>>>
>>>>> An object is not the same as a basic type.  A basic type holds one
>>>>> or more values.  An object can also have methods to operate on
>>>>> those values.  The two are not compatible.
>>>>>
>>>>
>>>> Could you tell me what these methods are?
>>>
>>> The object can be of any type, so the whole depends on the class
>>> definition.
>>>
>>> for example:
>>> class myclass {
>>>      public $array = Array();
>>>      public function getFirst() {
>>>          if(sizeof($this->array) == 0)
>>>          {
>>>              return null;
>>>          }
>>>          return $this->array[1];
>>>      }
>>> }
>>>
>>> this has the method getFirst.
>>>
>>
>> ???????
>> So what?
>
> It means that the ArrayObject is a built-in type allows an object to
> function as an array, as the PHP doc says.  Your user-defined object
> contains an array but does not function as an array, as the output from
> print_r() shows.
>

So there is no way to create an object (class) that can *also* function
as an array?

Re: ArrayObject vs array

<im4qbnFnmluU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=316&group=comp.lang.php#316

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Sun, 25 Jul 2021 11:48:39 +0200
Lines: 129
Message-ID: <im4qbnFnmluU1@mid.individual.net>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net> <sdgs5f$1suj$1@gioia.aioe.org>
<sdhgno$tt9$1@jstuckle.eternal-september.org> <sdj9us$o4p$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net D3Co8ZeO0W/edqFutk12lwKGd/ifQWYKj5kEUGW+uyik4SNZq9
Cancel-Lock: sha1:N2HeyoRz5TzLN02PrV+tnTVRk5k=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <sdj9us$o4p$1@gioia.aioe.org>
Content-Language: en-US-large
 by: J.O. Aho - Sun, 25 Jul 2021 09:48 UTC

On 25/07/2021 11.13, alex wrote:
> Il 24/07/21 18:56, Jerry Stuckle ha scritto:
>> On 7/24/2021 7:05 AM, alex wrote:
>>> Il 24/07/21 12:10, J.O. Aho ha scritto:
>>>> On 24/07/2021 08.26, alex wrote:
>>>>> Il 23/07/21 19:39, Jerry Stuckle ha scritto:
>>>>>> On 7/23/2021 5:16 AM, alex wrote:
>>>>>>> class C implements ArrayAccess, Countable, IteratorAggregate,
>>>>>>> Serializable {
>>>>>>>
>>>>>>>      private $container = ['a', 'b'];
>>>>>>>
>>>>>>>      public function offsetSet($offset, $value) {
>>>>>>>          if (is_null($offset)) {
>>>>>>>              $this->container[] = $value;
>>>>>>>          } else {
>>>>>>>              $this->container[$offset] = $value;
>>>>>>>          }
>>>>>>>      }
>>>>>>>
>>>>>>>      public function offsetExists($offset) {
>>>>>>>          return isset($this->container[$offset]);
>>>>>>>      }
>>>>>>>
>>>>>>>      public function offsetUnset($offset) {
>>>>>>>          unset($this->container[$offset]);
>>>>>>>      }
>>>>>>>
>>>>>>>      public function offsetGet($offset) {
>>>>>>>          return isset($this->container[$offset]) ?
>>>>>>> $this->container[$offset] : null;
>>>>>>>      }
>>>>>>>
>>>>>>>      public function count() {
>>>>>>>          return count($this->container);
>>>>>>>      }
>>>>>>>
>>>>>>>      public function getIterator() {
>>>>>>>          return new ArrayIterator($this->container);
>>>>>>>      }
>>>>>>>
>>>>>>>      public function serialize() {
>>>>>>>          return serialize($this->container);
>>>>>>>      }
>>>>>>>
>>>>>>>      public function unserialize($data) {
>>>>>>>          $this->container = unserialize($data);
>>>>>>>      }
>>>>>>>
>>>>>>>      public function getData() {
>>>>>>>          return $this->container;
>>>>>>>      }
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> print_r(
>>>>>>>          (array) new ArrayObject(['a', 'b'])
>>>>>>> );
>>>>>>> print_r(
>>>>>>>          (array) new C
>>>>>>> );
>>>>>>>
>>>>>>> Output:
>>>>>>>
>>>>>>> Array
>>>>>>> (
>>>>>>>      [0] => a
>>>>>>>      [1] => b
>>>>>>> )
>>>>>>> Array
>>>>>>> (
>>>>>>>      [Ccontainer] => Array
>>>>>>>          (
>>>>>>>              [0] => a
>>>>>>>              [1] => b
>>>>>>>          )
>>>>>>>
>>>>>>> )
>>>>>>>
>>>>>>> Because the result is not the same?
>>>>>>
>>>>>> An object is not the same as a basic type.  A basic type holds one
>>>>>> or more values.  An object can also have methods to operate on
>>>>>> those values.  The two are not compatible.
>>>>>>
>>>>>
>>>>> Could you tell me what these methods are?
>>>>
>>>> The object can be of any type, so the whole depends on the class
>>>> definition.
>>>>
>>>> for example:
>>>> class myclass {
>>>>      public $array = Array();
>>>>      public function getFirst() {
>>>>          if(sizeof($this->array) == 0)
>>>>          {
>>>>              return null;
>>>>          }
>>>>          return $this->array[1];
>>>>      }
>>>> }
>>>>
>>>> this has the method getFirst.
>>>>
>>>
>>> ???????
>>> So what?
>>
>> It means that the ArrayObject is a built-in type allows an object to
>> function as an array, as the PHP doc says.  Your user-defined object
>> contains an array but does not function as an array, as the output
>> from print_r() shows.
>>
>
> So there is no way to create an object (class) that can *also* function
> as an array?

- A class can have an variable that is an array.
- An array can hold objects.

You can make objects to have links to other objects (reference), then it
would be a bit array like at the same time it can hold it's data, the
problem will be that none of the array functions in PHP will work, so I
think you need to pick one of the two options that have to use real arrays.

--

//Aho

Re: ArrayObject vs array

<sdlqtr$i7a$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=320&group=comp.lang.php#320

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!XeyDHBeMmIt7nb5KMmJyiQ.user.46.165.242.91.POSTED!not-for-mail
From: 1j9448a02@lnx159sneakemail.com.invalid (alex)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Mon, 26 Jul 2021 10:14:51 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sdlqtr$i7a$1@gioia.aioe.org>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net> <sdgs5f$1suj$1@gioia.aioe.org>
<sdhgno$tt9$1@jstuckle.eternal-september.org> <sdj9us$o4p$1@gioia.aioe.org>
<im4qbnFnmluU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="18666"; posting-host="XeyDHBeMmIt7nb5KMmJyiQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Content-Language: it-IT
X-Notice: Filtered by postfilter v. 0.9.2
 by: alex - Mon, 26 Jul 2021 08:14 UTC

Il 25/07/21 11:48, J.O. Aho ha scritto:
>
> You can make objects to have links to other objects (reference),

That is?

> then it
> would be a bit array like at the same time it can hold it's data

That is?

Re: ArrayObject vs array

<im7ci0F9987U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=321&group=comp.lang.php#321

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Mon, 26 Jul 2021 11:11:28 +0200
Lines: 27
Message-ID: <im7ci0F9987U1@mid.individual.net>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net> <sdgs5f$1suj$1@gioia.aioe.org>
<sdhgno$tt9$1@jstuckle.eternal-september.org> <sdj9us$o4p$1@gioia.aioe.org>
<im4qbnFnmluU1@mid.individual.net> <sdlqtr$i7a$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net sp2lw+4cbmheckLmcwa2aQpObo0IDBFcvSHSqYLXOfTTaFK9WH
Cancel-Lock: sha1:JECZeaEdpCpSBwp4Ge0M03TotLU=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
In-Reply-To: <sdlqtr$i7a$1@gioia.aioe.org>
Content-Language: en-US-large
 by: J.O. Aho - Mon, 26 Jul 2021 09:11 UTC

On 26/07/2021 10.14, alex wrote:
> Il 25/07/21 11:48, J.O. Aho ha scritto:
>>
>> You can make objects to have links to other objects (reference),
>
> That is?

class myclass {
public $next;
public $data;
}

$a = new myclass();
$a->next = new myclass();
$a->next->next = new myclass();

>> then it would be a bit array like at the same time it can hold it's data
>
> That is?

$a->data = "my data";
$a->next->data = "next cell data";

--

//Aho

Re: ArrayObject vs array

<im7gccFa1nlU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=323&group=comp.lang.php#323

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: usenet@arnowelzel.de (Arno Welzel)
Newsgroups: comp.lang.php
Subject: Re: ArrayObject vs array
Date: Mon, 26 Jul 2021 12:16:44 +0200
Lines: 39
Message-ID: <im7gccFa1nlU1@mid.individual.net>
References: <sde1e5$p89$1@gioia.aioe.org>
<sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org>
<im277qF7fbjU1@mid.individual.net> <sdgs5f$1suj$1@gioia.aioe.org>
<sdhgno$tt9$1@jstuckle.eternal-september.org> <sdj9us$o4p$1@gioia.aioe.org>
<im4qbnFnmluU1@mid.individual.net> <sdlqtr$i7a$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net OWeWuzkCfN4J1Vv85l5lawQ72qIMfi8SjFeDXYJGnBNPkn+/Hp
Cancel-Lock: sha1:CxpkXAPCAjCYlmh8ErYb94zk8rc=
In-Reply-To: <sdlqtr$i7a$1@gioia.aioe.org>
 by: Arno Welzel - Mon, 26 Jul 2021 10:16 UTC

alex:

> Il 25/07/21 11:48, J.O. Aho ha scritto:
>>
>> You can make objects to have links to other objects (reference),
>
> That is?

<?php
$a = new Object();

// $b is a new reference ("link") to the object in $a and not(!) a copy

$b = $a;

// Now we change something in the object

$b->setName('foobar');

// This will return the same name wich was just set using $b since
// $b is just another reference to the object originally assinged to $a

$a->getName();
?>

If you need a copy of an object, you need to use the "clone" keyword:

<?php
$a = new Object();

// This will create a copy of the object in $b
$b = clone $a;
?>

--
Arno Welzel
https://arnowelzel.de

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor