PHP oop build array

Posted by Industrial on Stack Overflow See other posts from Stack Overflow or by Industrial
Published on 2010-05-28T14:00:43Z Indexed on 2010/05/28 14:01 UTC
Read the original article Hit count: 152

Filed under:
|
|

Hi!

If I would need to build up an array with OOP based PHP, would this be the proper way to do it?

class MyClass {

    $array = array();

    function addElement($value) {
        $this->array[] = $value;

    }

    function fetch() {

        $return = $this->memcached->getMulti($this->array);        

        return $return;
    }


}

PHP file where it will be used:

<?php

$this->myClass->addElement('key1');
$this->myClass->addElement('key1');
$this->myClass->addElement('key1');
$var = $this->myClass->fetch();

Thanks a lot

© Stack Overflow or respective owner

Related posts about php

Related posts about oop