Email : robin.singh@indopia.com
Contact :
9213721605
AGE : 25 years, 6 months and 24 days old
City : Noida-Sec-15
State : UP
Country : India
Industry : Web Metrix Services Pvt. Ltd.
Occupation : PHP (Web Developer)
Favorite : Cricket, Indian Movies(Tum Bin, Sirf Tum, Hum Dil De Chuke Sanam)
Wishlist : All Business Information
Current News
Indopia City Search
About Me :
Manzil unhi ko milti hai, Jinke sapno me jaan hoti hai,
Pankh se kuchh nahi hota, Hauslon se udaan hoti hai.
The Railways in India are the principal mode of transportation for freight and passengers. The railways have played an important role in the development of industries and agriculture.
Indian railways consist of a vast network of 7, 031 stations spread over a route length of 63, 221 km with a fleet of 7,817 locomotives, 5,321 passenger service vehicles, 4, 904 other coaching vehicles and 228, 170 wagons as on 31st March 2004.
Indian Railway has the distinction of being one of the biggest and busiest rail networks in the world carrying more than sixteen million passengers on a daily basis. In terms of headcount again Indian Railway scores as it employs more than 1.6 million employees that is only second to the Chinese Army in terms of people employed.
Spanning nearly two centuries Indian Railways has been serving the country with utmost pride. It was only in 1851 when the first train ran in the country for hauling construction material in Roorkee and by 1853 the first passenger train service became operational running between Bori Bunder, Bombay and Thane covering a distance of twenty one miles thus marking the formal birth of rail network in India.
The Indian Railways network binds the social, cultural and economical fabric of the country and covers the whole of country ranging from north to south and east to west removing the distance barrier for its people. The railway network of India has brought together the whole of country hence creating a feeling of unity among the Indians.
PHP-GTK is a PHP extension that enables you to write client-side, cross-platform GUI applications. This is the first extension for PHP of its kind, and was written in part to prove that PHP is a capable general-purpose language that is suited to more than just the web application environment.
This extension will not allow you to display GTK+ applications in a web browser. It is intended for creating standalone GUI applications.
example :
When you begin to learn a programming language, the first program you often write is a 'hello world' program. So, just to fit in with everyone else, the first tutorial in this manual just happens to be a 'hello world' tutorial!
Throughout the tutorials we expect a reasonable grasp of PHP itself. The tutorials are designed to give the user an idea of how to use PHP-GTK, and the ideas and techniques behind it.
In this tutorial we will create a simple window with the text "Hello World!" in it.
We will start by listing the program and will then explain each line of the program, giving an overview of a very basic PHP-GTK application.
Example 1.1. PHP-GTK Hello World Program ListingExample 1.2. Loading PHP-GTKExample 1.3. The delete_event() functiondelete-event"
<?php
if( !extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}
function delete_event()
{
return false;
}
function shutdown()
{
print("Shutting down...\n");
gtk::main_quit();
}
function hello()
{
global $window;
print "Hello World!\n";
$window->destroy();
}
$window = &new GtkWindow();
$window->connect('destroy', 'shutdown');
$window->connect('delete-event', 'delete_event');
$window->set_border_width(10);
$button = &new GtkButton('Hello World!');
$button->connect('clicked', 'hello');
$window->add($button);
$window->show_all();
gtk::main();
?>
|
<?php
if( !extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}
?>
|
These first few lines check to see if the PHP-GTK extension is already available, and loads it if it isn't. This is done by the dl('php_gtk.dll'); or dl('php_gtk.so'); statements on Windows and Linux respectively. The PHP_SHLIB_SUFFIX takes care of the specific extensions used by Windows and Linux.
<?php
function delete_event()
{
return false;
}
?>
|
The delete_event() function is registered as a handler (see below) for the " signal. It returns false, telling PHP-GTK to fire the event's default signal handler, which in this case is the destroy() method. If the function were to return true, PHP-GTK would stop the default signal handler running at this point. This is useful to know if you need to write a user-defined function in place of destroy() - for example, to produce a dialog box confirming that the user intends to close down the application.
It is not strictly necessary to return false in order to connect the "delete-event" signal to the destroy() method, as this particular signal returns false by default. It is possible to not specify any behaviour at all for a window's "delete-event" signal, just so long as the "destroy" signal is handled in the correct way, as it is here.
Example 1.4. The shutdown() functiondestroy"
<?php
function shutdown()
{
print("Shutting down...\n");
gtk::main_quit();
}
?>
|
The shutdown() function is registered as a handler for the " signal. The function prints the text "Shutting down...\n" to the console and then calls the static function gtk::main_quit() .
Example 1.5. The hello() functionclicked"
<?php
function hello()
{
global $window;
print "Hello World!\n";
$window->destroy();
}
?>
|
The hello() function is registered as a handler for the " signal on the button. It globalises the $window variable so it can access the instance of GtkWindow created further down the script. It then prints the text "Hello World" to the console before calling the destroy() method on the window, which in turn fires the "destroy" signal, which in turn calls the shutdown() function.
Another way that the hello() function would be able to access the $window variable is if the variable were passed as a custom parameter.
Example 1.6. Setting up the WindowGtkWindow
<?php
$window = &new GtkWindow();
$window->connect('destroy', 'shutdown');
$window->connect('delete-event', 'delete_event');
$window->set_border_width(10);
?>
|
The next four lines set up the window itself. Firstly we create an instance of . Once this has been done successfully, we call the connect() method from the window in order to register the shutdown() function as the handler for the "destroy" signal and the delete_event() function as the handler for the "delete-event" signal. Finally, we call the set_border_width() function to set a 10-pixel wide border on the instance of GtkWindow that we just created.
Example 1.7. Setting up the ButtonGtkButton
<?php
$button = &new GtkButton('Hello World!');
$button->connect('clicked', 'hello');
$window->add($button);
$window->show_all();
?>
|
These three lines of the script create and set up the button. In the first line of the above code snippet we create a new instance of the widget. The argument to the constructor is the text we want the button to display - in this case "Hello World!". We then call the connect() method to register the hello() function we defined earlier, as the handler for the "clicked" signal. Finally we add the button to the window we previously created by calling the GtkContainer method add() from our containing $window, and then display everything contained by $window (and its child widget, $button) by calling the show_all() method, also from our instance of GtkWindow.
Example 1.8. The call to gtk::main
<?php gtk::main(); ?> |
The final line of the script calls the static gtk::main function. This tells PHP-GTK that we have finished setting up our interface, and that the main loop can begin listening for the events fired by user interaction so that the callback functions we defined earlier can be called and the various actions carried out.


