This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $preferred_color = $colors[1]; //This will set our new variable | |
| //To ‘Green’ from index ‘1’ in the array | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $user_information = array( | |
| “Name” => “John Doe”, | |
| “Gender” => “Male”, | |
| “Age” => “42” | |
| ); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $user_information = array(); | |
| $user_information[“Name”] = “John Doe”; | |
| $user_information[“Gender”] = “Male”; | |
| $user_information[“Age”] = “42”; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $current_user_gender = $user_information[“Gender”]; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
| <title>Example</title> | |
| </head> | |
| <body> | |
| <div class=’age_notification’> | |
| <?php | |
| //We would like to output the user’s age here | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class=’age_notification’> | |
| <?php | |
| echo (“You are “ . $user_age); | |
| ?> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if($current_weather == “cloudy”){ | |
| $welcome_message = “It’s cloudy out, grab a jacket.”; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if($current_weather == “cloudy”){ | |
| $welcome_message = “It’s cloudy out, grab a jacket.”; | |
| } else { | |
| $welcome_message = “Looking good out there. Have fun.”; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if($current_weather == “cloudy”){ | |
| $welcome_message = “It’s cloudy out, grab a jacket.”; | |
| } else if($current_weather == “raining”){ | |
| $welcome_message = “It’s raining out, grab an umbrella.”; | |
| } else { | |
| $welcome_message = “Looking good out there. Have fun.”; | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| switch ($current_weather) { | |
| case “cloudy”: | |
| $welcome_message = “It’s cloudy out, grab a jacket.”; | |
| break; | |
| case “raining”: | |
| $welcome_message = “It’s raining out, grab an umbrella.”; | |
| break; | |
| default: | |
| $welcome_message = “Looking good out there. Have fun.”; |