lecture2 - CPSC431Databases&Applications Lecture2 PHPBasics...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
PHP Basics PHP Basics Lecture 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Escaping to PHP Escaping to PHP <h3>Welcome!</h3> <?php  print "<p>This is a PHP example.</p>"; ?> <p>Some static information found here. ..</p>  or <script language="php">  print "This is another PHP example."; </script> 
Background image of page 2
Embedding Multiple Code Blocks Embedding Multiple Code Blocks <html> <head> <title> <?php  echo "Welcome to my site!"; ?> </title> </head> <body> <?php $date = "May 18, 2003"; ?> <h3>Today's date is <?php =$date;?></h3> </body> </html> 
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Single Line Comments Single Line Comments <?php  // Title: My PHP program   // Author: Jason  print "This is a PHP program";  ?> Or <?php  # Title: My PHP program   # Author: Jason  print "This is a PHP program";  ?> 
Background image of page 4
Multiple-line Comments Multiple-line Comments <?php  /* Title: My PHP Program    Author: Jason      Date: October 10, 2005 */  ?> 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
print() print() <?php  print("<p>I love the summertime.</p>"); ?> <?php  $season = "summertime";  print "<p>I love the $season.</p>";  ?> <?php  print "<p>I love the  summertime.</p>"; ?> <?php  $season = "summertime";  print "<p>I love the ".$season."</p>"; ?> 
Background image of page 6
echo() echo() <?php  $heavyweight = "Lennox Lewis";  $lightweight = "Floyd Mayweather";  echo $heavyweight, " and ", $lightweight, " are great  fighters."; ?>  This code produces the following: Lennox Lewis and Floyd Mayweather are great  fighters. 
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
printf() printf() printf("$%01.2f", 43.2); // $43.20 printf("%d beer %s", 100, "bottles");  // 100 beer bottles Printf("%15s", "Some text");  // Some text %c  single character %d  integer %f  floating point number %s  character string %u  unsigned integer
Background image of page 8
Scalar Datatypes Scalar Datatypes Boolean $alive = false;       # $alive is false. $alive = 1;           # $alive is true. $alive = -1;          # $alive is true. $alive = 5;           # $alive is true. $alive = 0;           # $alive is false.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Scalar Datatypes Scalar Datatypes Integer 42              # decimal -678900      # decimal 0755         # octal 0xC4E        # hexadecimal The maximum supported integer size is platform-dependent, although  this is typically positive or negative 2 31 . If you attempt to surpass 
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/20/2009 for the course CPSC CPSC431 taught by Professor Prf.wang during the Spring '09 term at CSU Fullerton.

Page1 / 36

lecture2 - CPSC431Databases&Applications Lecture2 PHPBasics...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online