php
play

PHP Dr. Steven Bitner Your UMKC PHP account - PowerPoint PPT Presentation

PHP Dr. Steven Bitner Your UMKC PHP account http://kc-sce-sphp01.kc.umkc.edu/~SSO SSO is your UMKC username, e.g. bitners Use an SSH program such as PuTTY to create code Alternatively, you can write code on your local machine and


  1. PHP Dr. Steven Bitner

  2. Your UMKC PHP account  http://kc-sce-sphp01.kc.umkc.edu/~SSO  SSO is your UMKC username, e.g. bitners  Use an SSH program such as PuTTY to create code  Alternatively, you can write code on your local machine and upload with Filezilla or other SFTP clients

  3. Connecting in PuTTY  Machine name: kc-sce-sphp01.kc.umkc.edu  Use default port of 22  Connection type: SSH (default)  Enter SSO as username and standard school password as password

  4. Linux  ls  lists files in the current directory  cd DIRNAME  changes to the directory DIRNAME  vi FILENAME  opens FILENAME for editing using vim  rm FILENAME  deletes FILENAME  There is no ‘recycle bin’ in Linux  mv FILENAME NEW_FILENAME  moves a file from one location to another

  5. Vi  How it functions is controlled by ~/.vimrc  Save - :w  Quit - :q  Find a string - /string or ?string  Find next occurrence of current string - *  Auto-complete – ctrl+n or ctrl+p  Vim is the most powerful text editor you will ever use  Steep learning curve

  6. What is PHP?  Stands for PHP Hypertext Preprocessor  C-like server side scripting language  Designed for the web

  7. PHP.net  Strong community support base  With that comes good and bad code  Can be difficult to tell the difference between what worked and what is a ‘best practice’  All standard PHP functions and example code

  8. Why use PHP?  Very fast  Easy database interoperability  Free  Easy to learn and use  It’s what you’ll be tested and graded on  You can accomplish just about anything with it

  9. Variables  Do not need to declare variables  Prefix all variables with a dollar sign $myVariable = ‘CS /IT 490 WD’;  PHP can also use variable variables, we’ll discuss this more toward the end of the semester $name = ‘Steven’; $Steven = ‘A really cool guy’; echo $$name; // outputs ‘A really cool guy’

  10. Loose typing $groceries = ‘4 bags’; // assigned a string value $groceries++; echo $groceries; // ouputs 5

  11. Comparison operators  Like javascript  === is not the same as ==  if (strpos (‘Hello’,’He’)) { }

  12. echo  How to output text (this is what makes html pages)  Can also use print, but it is a slower operation

  13. print_r ( ) and var_dump ( )  Used in debugging  Outputs all contents of arrays

  14. Heredoc echo <<< ENDHTML lots of output here ENDHTML;

  15. Strings  Can enclose strings in ‘’ or “”  ‘’ does not interpret $myVariable = ‘ Booyah ’; echo ‘Value: $ myVariable ’;  outputs Value: $myVariable echo “Value: $ myVariable ”;  outputs Value: Booyah

  16. Concatonation  use the . echo “Hello” . “class”; $myVariable = ‘I can \ ’t believe it is already ‘; $month = ‘September’; $text = $myVariable; $text .= $month;

  17. Variables in strings  Variable names will not work correctly when they are adjacent to any character that is a valid part of a variable name  echo “My value is $ myVariableand there is nothing you can do about it”;  echo “My value is ${ myVariable}and there is nothing you can do about it”;

Recommend


More recommend