Workshop in Computational Bioskills - Spring 2006 Lesson 9 - PHP Basics Introduction Variables Arrays Control Flow
File Hello_world.php: <html> <head> <title> PHP Hello </title> </head> <body> <b> <? print "Hello World!" ?> </b> </body> </html>
But that was not really dynamic (why?). Let's see for example how to create a simple_form.php. If you want, recall how to write form in Lesson 7.
Strings appear in three formats: Single quotes: <? print 'That\'s your name: $name' ?> // That's your name: $name Double quotes: <? print "Your name is $name" ?> // Your name is Dubi Here-document (Heredoc) syntax: <? print <<< HTMLBLOCK <html> <body> some text... </body> <html> HTMLBLOCK ?> Prints all the text between the HTMLBLOCK tagsUseful string functions
o Like the perl scalars. o Naming convention - letters, underscore and numbers (not in the beginning). o Arithmetic operations permitted: just like perl. o Variables inside strings: $preparation= 'Braise'; $meat = 'Beef'; print "{$preparation}d $meat with Vegetables"; // Braised Beef with Vegetables