Class not functioning

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

 



Hey everyone, I just delved into classes recently and have been having
moderate success so far.

I have a puzzler though.

I have the following class decalred and instantiated:

class Notify {
 var $q = array();

 public function addtoQ($string, $class)
 {
  $message = '<span class="'. $class .'">'. $string .'</span>';
  $this->q[] = $message;
 }

 public function printQ()
 {
  if (isset($q))
  {
   echo '<p align="center" class="notification">';
   foreach($this->q as $msg)
   {
    echo $msg ."\n";
   }
   echo '</p>';
  }

  return;
 }

 function __destruct()
 {
  if (isset($q))
  {
   unset($this->q);
  }
 }
} // END CLASS Notify


And in my script, I call it like so:
$Notif = new Notify;

I have run other statements in other classes that should be adding to the $q
array (ie. Notify::addtoQ('ERROR! There Was An Error Updating The
Database!', 'error');)

However, when I try to get my webpage to display them using:

$Notify->printQ();

it does not seem to want to loop through this array (and print the
messages). I am getting NO error message, in fact everything 'looks' fine,
I'm just not seeing the appropriate message.

Any help would be appreicated!

[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