SitePlay Tutorials: SitePlay Tutorials PHP TUTORIALS 1
Past: Past ELIZABETH “Jake” feinler 2
Present:: Present: Chapter 5 Strings 3
PowerPoint Presentation: $name = “ Meke ”; $name[2] = “K”; // Replaces “k” with “K” // Outputs altered string echo $name[2]; 4
PowerPoint Presentation: $ favoriteAnimal = “cat”; Echo “My favorite animals are {$ favoriteAnimal }s”; 5
PowerPoint Presentation: Heredoc / Nowdoc structure or layout: The variable name: $ nameHere the assignment character: = the three left carrots or less than signs: <<< the beginning identifier/name: NAMEHERE (‘NAMEHERE’ if nowdoc ) the string in all its glory: some string here the ending semicolon at the end of the string: ; the end identifier/name: NAMEHERE 6
PowerPoint Presentation: Instead of: $ myString = “Hello, world!”; if ( ! strpos ( $ myString , “Hel” ) ) echo “Not found”; Write as: $ myString = “Hello, world!”; if ( strpos ( $ myString , “Hel” ) === false ) echo “Not found”; 7
Present:: Present: Chapter 6 arrays 8
PowerPoint Presentation: $ arrayLove [2] = “Love rules”; $ arrayLove [] = “ Supreme!”; 9
PowerPoint Presentation: $ myBook = array( “title” => “The Grapes of Wrath”, “author” => “John Steinbeck”, “ pubYear ” => 1939 ); 10
PowerPoint Presentation: foreach ($array as $ arrayValue ) { // Do some stuff with this current array value } unset($ arrayvalue ); foreach ($array as $ arrayKey => $ arrayValue ) { // Do some stuff with this current array key // and value } 11
SitePlay Tutorials: SitePlay Tutorials PHP TUTORIALS 12