« Embeder – a free PHP to EXE solution | Home | Changing the application name of a GtkAboutDialog in PHP-GTK2 »
Stopping the “PHP Fatal error: Internal object missing in” error in PHP-GTK2
By admin | August 16, 2008
In PHP-GTK2, if you build your own class of an existing PHP-GTK2 class, you may encounter one of the following errors:
- “PHP Fatal error: Internal object missing in YourclassName wrapper in /path/to/your/script on line *”
- “Fatal error: Internal object missing in YourclassName wrapper in /path/to/your/script on line *”
This is somehow (not documented) caused by not calling parent::__construct(), the parent constructor. For example, try to run the following snippet:
<?php
if (!class_exists(‘gtk’)) {
die(“ERROR: No PHP-GTK2 Module.\n”);
}
class Myclassw extends GtkWindow {
protected $label;
function __construct() {
$label = new GtkLabel(“Hello World – will fail”);
$this->add($label);
$this->show();
$this->show_all();
Gtk::main();
}
}
$a = new Myclassw();
?>
You should receive the following errors: (path may be different)
- PHP Fatal error: Internal object missing in Myclassw wrapper in /usr/dev/php5/gtk2/bug.php on line 14
- Fatal error: Internal object missing in Myclassw wrapper in /usr/dev/php5/gtk2/bug.php on line 14
Now, try this snippet:
<?php
if (!class_exists('gtk')) {
die("ERROR: No PHP-GTK2 Module.\n");
}
class Myclassw extends GtkWindow {
protected $label;
function __construct() {
parent::__construct(); // New line inserted here
$label = new GtkLabel(“Hello World – will work!”);
$this->add($label);
$this->show();
$this->show_all();
Gtk::main();
}
}
$a = new Myclassw();
?>
Now this time, it should work as expected. If you encounter “ERROR: No PHP-GTK2 module.”, this means that you are either running it in your web server or ran it without php-gtk2.(so/dll) in your php.ini.
All tests were ran on Ubuntu Linux 8.04, PHP 5.2.4-2ubuntu5.3 and Linux kernel version 2.6.24-19-generic. If this article helped you solve the problem, please help us spread the word or please leave a comment. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!
If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!
Topics: Linux, PHP, Windows | 7 Comments »
July 20th, 2024 at 21:28
… [Trackback]
[…] Find More on on that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]
August 9th, 2024 at 22:15
… [Trackback]
[…] Read More to that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]
August 17th, 2024 at 19:11
… [Trackback]
[…] Read More to that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]
August 26th, 2024 at 19:30
… [Trackback]
[…] Find More on to that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]
September 4th, 2024 at 22:44
… [Trackback]
[…] Information to that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]
September 24th, 2024 at 23:04
… [Trackback]
[…] Find More Information here on that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]
September 27th, 2024 at 22:06
… [Trackback]
[…] Find More on on that Topic: compdigitec.com/labs/2008/08/16/stopping-php-fatal-error-internal-object-missing-in-error-in-php-gtk2/ […]