Skip to content

den-wdi-2/php-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

PHP Exercises

Now that we know the basics of PHP, see how many of the following tasks you can accomplish. Use the previous lesson as a resource.

The Tasks

Turn on your MAMP server, create a folder inside your MAMP working directory called php_exercises, and create a file called index.php. You will do all your work inside this file.

Once you have this file, go to http://localhost:8888 in your browser and navigate to your php_exercises folder. This should show a blank page...but not for long!

  1. Get php to echo "Hello World!"
  2. Replace World with a variable called $place and use string concatenation to echo the new string.
  3. Get php to echo all numbers from 1 to 20
  4. Create a variable called $name, and save a string to it (your name or a friend's name)
  5. Create three <p> tags, one that says "Name Too Short", one that says "Name Long Enough", and one that says "Name Has No Length"
  6. Using conditionals, have the <p> tags show up if $name is less than 5 characters, greater than or equal to 5 characters, and for any other case, respectively.
  7. Create a class for animal with three properties. Echo these properties to the browser. Make sure you're using the right type of properties that allow you to echo them outside of the class declaration.
  8. Create a class for cat that extends animal and has three additional properties. Echo all six of cats properties to the browser.
  9. Get php to echo three simple math problems and their solutions.
  10. Create an array of 7 numbers, and print all the values out to page.
  11. Create an associative array of three names and their ages, and print all the names and ages out to page.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published