Skip to main content

Instructions: print the string "Hello World" inside the div below with class name 'result'.

Hello World

Instructions: echo the following statement inside the div below with class name 'result'

“Twinkle, Twinkle little star.”

Next, create two variables, one for the word “Twinkle” and one for the word “star”. Echo the statement to the browser, this time substituting the variables for the relevant words. Change the value of each variable to whatever you like, and echo the statement a third time. Remember to include code to show your statements on different lines..

Twinkle, Twinkle little star.
Twinkle, Twinkle little star.
Thunder, Thunder little elephant.

When you are writing scripts, you will often need to see exactly what is inside your variables. For this PHP exercise, think of the ways you can do that, then write a script that outputs the following, using the echo statement only for line breaks.
string(5) "Harry"
Harry
int(28)
NULL

string(5) "Harry"
Harry
int(28)
NULL

In this PHP exercise, you will use a conditional statement to determine what gets printed to the browser. Write a script that gets the current month and prints one of the following responses in the div with class name 'result', depending on whether it's August or not:
It's August, so it's really hot.
Not August, so at least not in the peak of the heat.

Hint: the function to get the current month is 'date('F', time())' for the month's full name.
Hint: this will be an if/else statement

Not August, so at least not in the peak of the heat.

For this exercise, you will create an unordered list of ten of the largest cities in the world. Create an array with the following values: Tokyo, Mexico City, New York City, Mumbai, Seoul, Shanghai, Lagos, Buenos Aires, Cairo, London.
A. Print these values to the browser separated by commas, using a loop to iterate over the array.
B. Print the first 5 values from the array into an HTML structured Unordered list (this is a 'ul' tag containing 'li' tags)

Tokyo, Mexico City, New York City, Mumbai, Seoul, Shanghai, Lagos, Buenos Aires, Cairo, London,
  • Tokyo
  • Mexico City
  • New York City
  • Mumbai
  • Seoul