Re: [PHP] PHP 4 OOP, re-using a object?
On 9/10/06, Micky Hulse <micky@ambiguism.com> 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.
|