Presentation is loading. Please wait.

Presentation is loading. Please wait.

INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.

Similar presentations


Presentation on theme: "INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014."— Presentation transcript:

1 INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014

2 Why PHP?

3 #1 Server-side language http://w3techs.com/technologies/overview/programming_language/all PHP is used by 81.6% of all the websites whose server-side programming language we know.

4 Very Productive & Popular https://gist.github.com/paulmillr/2657075/ > 230 followers Top contributors are PHP devs

5 It’s FREE. Open Source Stack Low barrier to entry. Download LAMP/WAMP, start now!

6 But…

7 It’s SLOW! http://www.lornajane.net/posts/2012/php-5-4-benchmarks It’s getting faster and faster Time to run benchmark script

8 Scalability, Enterprise-ready? Facebook is written in PHP HipHop for PHP Also Drupal/Wordpress

9 More Information http://www.acquia.com/blog/why-php-real

10 Open PHP in the Browser Homework = use Eclipse, but we will use this online compiler for lecture http://www.compileonline.com/execute_php_online.php

11 What is PHP? (Recursive acronym) PHP: Hypertext Preprocessor Originally Personal Homepage

12 Scripting language Originally PHP interpreter (like javascript) Now = compiled to bytecode (like java) Cross-platform! Script = no persistent memory My favorite part of PHP: End of script = everything is erased PHP code Bytecode Apache Compile at run time Run at run time

13 Server-side language Compiled & executed on Server Client does not see code ex: Javascript is client-side

14 index.php Default page!

15 Data Types $myBool = TRUE; $myInt = 10; $myWord = "hello world"; $myArray = array("ice cream", "steak", "apples"); $myArray[0] // ice cream $myKeyValuePair = array("Dad" => "Joe", "Mom" => "Amy", "Bro" => "Jason"); $myKeyValuePair['Dad'] // Joe

16 Dynamic, loosely typed language Loosely typed (vs. strong typed) “10” + 1 => 11 javascript => 101 C/C++ => ERROR!!! Dynamic typed (vs. static) $temp => from int to array C/C++ => ERROR!!! Cause of perf issues

17 == and === are different!!

18 Single Quote vs. Double Quote

19 For, While, Foreach (loops) Same as other languages Foreach => great for associative arrays (key/value pair) What if we want to use for loop to access associative arrays? Answer = Search on Google! “php array keys”

20 PHP manual is your best friend http://www.php.net/manual/en/index.php

21 Classes, Objects, Functions Class method/function call Class variable/member variable Default Public (unlike C++ default is Private) Protected = can be seen by subclass Property (method for variable, allows public read, private write) Parameters for function calls ex: toUpper($word) No type! Not like C++! Static Functions, use ::

22 Other PHP constructs $_REQUEST => get/post request form params require_once("file.php"); // #include, import isset($_REQUEST['id']) || die('missing id'); echo // cout, System.printout.ln var_dump() // must use during dev

23 Connecting to MySQL Hint: Search on google for PDO in PHP More details in next topic “Intro to Databases” Wanted to note here incase you’re starting PA1 this weekend


Download ppt "INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014."

Similar presentations


Ads by Google