Re: PHP 4 OOP, re-using a object?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/10/06, Micky Hulse <micky@xxxxxxxxxxxxx> wrote:
Christopher Weldon wrote:
> What's the error, and how do you have the class and functions defined?

Hi Christopher, thanks for asking.  :)

Actually, it was one of those silly, right in front of my face, logic
errors...

class RandomSplash {
var $alphabet = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm');
function randomize($what) {
        switch($what) {
                case 'css':
                $data = $this->$alphabet;
                ...
                ...
                ...
}
}

See the error?

For future reference it is best you provide a full code example in
what your problem is when you ask the question, Asking if it something
is proper isn't going to get you far.

<?php   echo $am_somevar; ?>

is perfectly valid but accoring to the mistake you had you should have
been using:
<?php echo $I_am_somevar;?>

It would have been more relevant to supply the problem along with the solution.


$data = $this->$alphabet;

should've been:

$data = $this->alphabet;

At first I thought it was how I was calling the class... all works now
though.  :)

Good to hear you got it resolved..

Curt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux