Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP Training Senior Design team Ongo8 Sunday October 16, 2005.

Similar presentations


Presentation on theme: "PHP Training Senior Design team Ongo8 Sunday October 16, 2005."— Presentation transcript:

1 PHP Training Senior Design team Ongo8 Sunday October 16, 2005

2 Development Environment 1/2  Download WinSCP: ongo8.ece.iastate.edu/ongo8/phptraining/winscp.ex e  Start WinSCP  Host name: ongo8.ece.iastate.edu  Ask leader for username and password  Directories -> Remote directory: /var/www/html/ongo8/phptraining  Drag and drop both PHP files to desktop

3 Development Environment 2/2  Go up a folder to “ongo8” and enter into your group’s directory, then into your personal directory  If you don’t have a personal directory, go to: Commands->Create Directory… and make yourself one  Drag both php files from your desktop into your personal directory  Double click on the file “simple.php”

4 Syntax  General syntax:  Code is enclosed in tags.  Like C, Java, Perl, etc., each instruction ends with a semicolon  PHP supports C, C++ and shell style comments.  /* multi-line comment */  # shell one line comment  // one line C++ comment  NOTE: one line comments refer to the end of the line (\n character) or end of PHP instruction (;) whichever comes first

5 Basic PHP  Your first PHP enabled web page!!  Add the following code somewhere:  echo " Hello World ";  Open the web page in your browser: ongo8.ece.iastate.edu/ongo8/group/username/simple.ph p  Now add this:  phpinfo();  Open the web page again

6 Variables  Four scalar variables: boolean, integer, float, string  Two compounds: array, object  Variables start with a “$”  Use var_dump(); to see type and value of a certain variable. Very useful for debugging!!  Example code: $bool = TRUE; // a boolean $str = "foo"; // a string $int = 12; // an integer var_dump();

7 Flow Control  If/else/elseif statements are used just like in C if (condition) { // …do this if true..; } else { //do this otherwise }  switch, for, while, etc. statements are just like in C too

8 Arrays //Declare an empty array $errors = array(); //Add values to the array $errors[] = ‘this goes in index 0’; $errors[] = ‘this goes in index 1’; $errors[‘err15’] = ‘this goes in index err15’; //Print those values echo " index 0: ". $errors[0]. " "; echo "index err15: ". $errors['err15']. " "; //Declare an array with pre-defined entries $teachers = array('John'=>’Lamont’, ‘Pat’=>’Patterson’); //Print the array print_r();

9 Includes  Includes are similar to C: include 'lib.authentication.php';  Will basically paste the contents of lib.authentication.php wherever the include statement is  Also can use:  include_once  require  require_once

10 Objects  PHP has very limited support for objects (at least for the version of PHP we’re using)  Can have both constructors and methods  Has no understanding of Public, Private, etc.  Calling the constructor: $userData = new User($fname, $mname, $lname, $notes, $owner, $permission, $username, $password, $passwordh, $permission, $username, $password, $passwordh, $startdate, $stopdate, $studentid, $email); $startdate, $stopdate, $studentid, $email);  Calling a method: $permission = $userData->getPermission();

11 Tips and Tricks  Use the php.net documentation, it’s very useful and convenient  Use google  Ask around if you have a question  Don’t use an HTML editor, it messes up PHP code in some people’s experience  Most secure ftp clients let you edit remote files in a local text editor. I use WinSCP.

12 New Stuff  Authentication (You don’t have to worry about this.)  Quiz timing (Javascript and PHP)

13 Questions & Comments??


Download ppt "PHP Training Senior Design team Ongo8 Sunday October 16, 2005."

Similar presentations


Ads by Google