$menu->append( &new GtkMenuItem) can't be written that way ?
| From: | Markus Fischer | Date: | Mon, 09 Apr 2001 21:25:42 +0000 |
| Subject: | $menu->append( &new GtkMenuItem) can't be written that way ? | ||
| Groups: | php.gtk | ||
| Request: | Send a blank email to php-gtk+get-1329@lists.php.net to get a copy of this message | ||
Hi,
$menu = &new GtkMenu();
foreach( $menuitems as $menuitem)
$menu->append( &new GtkMenuItem( $menuitem));
does not work, getting parse error in the 3rd line:
parse error, expecting
T_VARIABLE' or '$''
Instead it must be writte this way :
$menu = &new GtkMenu();
foreach( $menuitems as $menuitem) {
$tmp = &new GtkMenuItem( $menuitem);
$menu->append( $tmp);
}
Can someone enlighten me why this and what I'm doing wrong in the
first example (or what causes it not to work ?)
Or, is it safe to write :
$menu = &new GtkMenu();
foreach( $menuitems as $menuitem)
$menu->append( new GtkMenuItem( $menuitem));
which gives no parse error but also does not work correctly
thanks,
Markus
--
Markus Fischer, http://josefine.ben.tuwien.ac.at/~mfischer/
EMail: mfischer@josefine.ben.tuwien.ac.at
PGP Public Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0