O'Reilly logo

Advanced PHP for Web Professionals by Christopher Cosentino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Putting It All Together

So now you know how to make a label, a button (with a label in it), and a text entry field. With these three tools, you can begin to build an application!

First, we need to know how to get the text the user enters in the text entry widget. The GtkTextEntry widget has a method that meets our needs:

$input = $text1->get_text(); 

You can assign the user-entered data using the get_text() method on the $text1 object to a variable (for example $input), then do whatever you want with that text. The following script puts it all together and provides a short example of a function to handle the user-entered text. See Figure 12-6 for example output.

Script 12-4. text_submit.php
					1.  <?php
 2.    if (!class_exists('gtk')) {
 3.  if (strtoupper(substr(PHP_OS, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required