Re: &new vs. new

From: Date: Thu, 18 Dec 2003 01:52:22 +0000
Subject: Re: &new vs. new
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4305@lists.php.net to get a copy of this message
http://www.php.net/references that along with the fact that doing stuff in constructors is a little flaky/unpredictable.. I normally end up writing class x { function &construct() { $t = &new x; ... do stuff... return $t; } } $a = &x::construct(); Regards Alan Ömer Rauf Atay wrote:
this code gives the following error: --------------------------------------------------------- <? if(!class_exists("gtk")) {
    if (strtoupper(substr(PHP_OS, 0,3) == "WIN"))
      dl("php_gtk.dll");
    else
      dl("php_gtk.so");
} $helpWindow = &new HelpWindow(); gtk::main(); class HelpWindow extends GtkWindow {
    var $hPaned;
    function HelpWindow()
    {
      parent::GtkWindow();
      $this->set_title("Help");
      $this->connect("destroy", array(&$this, "quit"));
      $this->hPaned = &new GtkHPaned();   //*********************** line 22
      $this->add($this->hPaned);
      $this->show_all();
    }
    function quit()
    {
      gtk::main_quit();
    }
} ?> --------------------------------------------------------- Fatal error: Cannot create references to/from string offsets nor overloaded objects in ....\help.ght on line 22 --------------------------------------------------------- When i change the "&new GtkHPaned()" to "new GtkHPaned()" the problem is solved. What is the actual difference between &new and new, and why is that error occurs?
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.gtk.general (#4305) next »