GTK inheritance oddity
| From: | david lazar Butcher | Date: | Sun, 17 Mar 2002 05:50:28 +0000 |
| Subject: | GTK inheritance oddity | ||
| Groups: | php.gtk.cvs | ||
| Request: | Send a blank email to php-gtk-cvs+get-486@lists.php.net to get a copy of this message | ||
I'm primarily a C++ programmer and am probably pushing PHPs OO but I don't understand why the enclosed code fails (for Bonk but not NoBonk). Does it have something to do with GtkTable being a wrapper to a C class?
I can work around this problem (using an external array of references with an entry for each Bonk instance, ugh), but its seems like it may be a bug in either PHP or PHP/GTK?
thanks for any insight you can provide,
david
======
Output:
X-Powered-By: PHP/4.2.0-dev
Content-type: text/html
<br />
<b>Fatal error</b>: Cannot create references to/from string offsets nor overloaded objects in <b>test.php</b> on line <b>25</b><br />
=====
Code:
<?php
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
class Foo
{
var $i;
function Foo($i)
{
$this->i = $i;} } class Bonk extends GtkTable { var $foo; function Bonk($f) {
$this->foo = &$f;} } class NoBonk extends Foo { var $foo; function NoBonk($f) {
$this->foo = &$f;} } $f = &new Foo(0); $b = &new NoBonk($f); $f = &new Foo(0); $b = &new Bonk($f); ?>