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

php
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1
  • Dr. Steven Bitner

PHP

slide-2
SLIDE 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

slide-3
SLIDE 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

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 6

What is PHP?

 Stands for PHP Hypertext Preprocessor  C-like server side scripting language  Designed for the web

slide-7
SLIDE 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

slide-8
SLIDE 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

slide-9
SLIDE 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’

slide-10
SLIDE 10

Loose typing

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

slide-11
SLIDE 11

Comparison operators

 Like javascript

 === is not the same as ==  if (strpos(‘Hello’,’He’)) { }

slide-12
SLIDE 12

echo

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

slide-13
SLIDE 13

print_r ( ) and var_dump ( )

 Used in debugging  Outputs all contents of arrays

slide-14
SLIDE 14

Heredoc

echo <<< ENDHTML lots of output here ENDHTML;

slide-15
SLIDE 15

Strings

 Can enclose strings in ‘’ or “”  ‘’ does not interpret

$myVariable = ‘Booyah’; echo ‘Value: $myVariable’;

 outputs Value: $myVariable

echo “Value: $myVariable”;

 outputs Value: Booyah

slide-16
SLIDE 16

Concatonation

 use the .

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

slide-17
SLIDE 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”;