views:

13

answers:

1
+1  Q: 

PHP GTK short path

I have the following PHP GTK code located in C:\gtk

<?php
if (!class_exists('gtk')) {
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Background');
$wnd->set_resizable(false);
$wnd->set_position(GTK_WIN_POS_CENTER);

$wnd->connect_simple('destroy', array('gtk', 'main_quit'));

$im = GtkImage::new_from_file("C:\gtk\bg.jpg");
$wnd->add($im);

$wnd->show_all();
Gtk::main();
?>

It shows the image C:\gtk\bg.jpg but my question is how can I display it from a local path. The PHP file is located in that folder so I should only have to type bg.jpg but that doesn't work.

+1  A: 

Use

$im = GtkImage::new_from_file(dirname(__FILE__)."\bg.jpg");
Mark