Hi,
I m vishal jayaswal. I m doing my BE from Agra and i m working on PHP.
At present i m creating an small application for adding two numbers.
Enter forst number in one text box and second number in other text
box. When you click the button Result, sum of both the number thta are
entered in both the text boxes, shown in result text box. but this
code create an error when i run this code:
<?
if (!class_exists('gtk'))
{
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
function delete_event()
{
return false;
}
function destroy()
{
Gtk::main_quit();
}
function result($button, $window)
{
$gettext1 = $ent1->get_text();
$gettext2 = $ent2->get_text();
$result = $gettext1 + $gettext2;
$ent3->set_text($result);
}
function test1()
{
global $window;
global $ent1;
global $ent2;
global $ent3;
$window->destroy();
}
$window = &new GtkWindow();
$window->set_name('Main Window');
$window->set_title('Introduction to PHP-GTK');
$window->connect('destroy', 'destroy');
$window->connect('delete_event', 'delete_event');
$window->set_border_width(5);
$window->set_position(GTK_WIN_POS_CENTER);
$frame = &new GtkFrame('Calculator');
$window->add($frame);
$table = &new GtkTable(3, 2, false);
$frame->add($table);
$num1 = &new GtkLabel('Number1: ');
$num2 = &new GtkLabel('Number2: ');
$ent1 = &new GtkEntry();
$ent2 = &new GtkEntry();
$ent3 = &new GtkEntry();
$button = &new GtkButton('Result');
$button->connect('clicked', 'result', '$window');
$table->attach($num1,0,1,0,1);
$table->attach($num2,0,1,1,2);
$table->attach($button,0,1,2,3);
$table->attach($ent1,1,2,0,1);
$table->attach($ent2,1,2,1,2);
$table->attach($ent3,1,2,2,3);
$window->show_all();
Gtk::main();
?>
Error Occured:
C:\php4>php c:\php4\test\test1.php
Fatal error: Call to a member function on a non-object in
c:\php4\test\test1.php
on line 23
Please send me the solution of this problem.