Re: use of = &new object versus = new object
| From: | Andrei Zmievski | Date: | Mon, 11 Jul 2005 23:17:13 +0000 |
| Subject: | Re: use of = &new object versus = new object | ||
| References: | 1 2 3 4 5 6 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5988@lists.php.net to get a copy of this message | ||
If you read my slides, you would see that there are three exceptions as to when you need to use &new.
1) When passing temporary objects to functions:
do_this(new GtkVBox());2) When using globals:
global $foo;
$foo = new GtkVBox();
3) When assigning to properties of objects derived from GtkObject:
$window = &new GtkWindow();
$window->box = new GtkVBox();
-Andrei
On Jul 11, 2005, at 1:32 PM, Jake Gordon wrote:
Thanks for all the replies. Still a bit confused though! Andrei Zmievski wrote:Trust me, you need to use &new in PHP-GTK 1. You may not see any problems right away, but they will crop up.But the funny thing is, with some code I had trouble with before I found that dropping the & was the only way to get it to work. Probably more to do with poor coding on my part though, but it took me three hours to solve the damn problem and that's how I solved/hacked it. This was, I think, the code: --- $button->connect('clicked', 'change_main', $section); function change_main($button, $section, $main) {global $layout, $main;// First destroy what was here before, if anything if($main) $main->destroy();$main = &new GtkLabel($section); // remove & to work $layout->put($main,100,40); $main->show();} --- Jake. -- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php