This assignment is worth a total of 100 points.
This assignment will focus on some of the basics of the PHP programming language.
Resource Files
The files you will need to complete this assignment are located in this files folder.
This assignment is worth a total of 100 points.
This assignment will focus on some of the basics of the PHP programming language.
The files you will need to complete this assignment are located in this files folder.
This assignment will require that you have access to a PHP environment of some type. While you can use whatever PHP environment you wish for development and testing, you will be graded on the performance of your code on the AWS Virtual Machines set up for you for the class.
Specifics of the AWS Virtual Machines:
Create a new html file setup.php and place it inside your html folder on your class VM. It should be accessible by going to http://xx.xx.xx.xx/setup.php where the IP address is the current one assigned to your VM. The contents of the file should just contain your name, and the following PHP code:
echo time();
There are two PHP files given to you for this problem: problem1.php and problem1_library.php. Your task will be to modify problem1_library.php and add various functions to it that will be called from problem1.php. You may want to modify problem1.php as you work, to comment out various function calls before you're ready for them, but we will use a new copy of the file when grading your work.
As a starting point, you are given one function, stringCat() as an example. You can see how this function is called from within problem1.php. You will create a total of eight more functions, and one new PHP class in the problem1_library.php file.
The various function calls inside of problem1.php are commented out initially. As you begin to work on each part, un-comment the appropriate function calls within problem1.php
You may not know what the current error reporting levels are set at for your environment. For this part create a new function setErrorLevel() that takes no arguments. Make sure that the error reporting levels include only the following items:
Your function will be called first to set the levels, then the current error reporting levels will be printed to the screen.
Create a new function named myStringCleanup which takes a single string argument. Do the following to the incoming string, and return the result:
Create a new function named oddEven which takes a single numerical argument. Determine if the number is odd or even, and return either the string "odd" or the string "even" for each case.
Create a new function named buildArray which takes four arguments. Take these four arguments and create an array with them. Return your newly created array.
In the files folder there is a text file: external_file.txt. Create a function called readLocalFile that takes no arguments. This function should do the following:
Create a new function serverSoftware which takes no arguments. In this function, determine what sort of server software the current PHP environment is running in. Return this as a string. Note that your server software string may differ from the one in the screenshot below. As long as its close that's fine. The one in my screenshot is taken from the AWS Virtual Machines set up for the class.
This part is a little more involved. You will first need to flesh out a PHP Class named mySimpleClass. The skeleton of the class is given to you. You will need to do the following within the class:
Create a new function makeObject which takes one argument, a secret string. In this function, do the following:
Create a new function getDatatype which takes one argument. In this function, determine the PHP Data Type, and return it as a string.
Once you have all the parts finished, your page should look something like the following screenshot. There may be minor differences in parts f and g, but the others should look the same.
For this problem you will create a simple PHP Web Page, and add a small bit of server side logic to it.
In the files folder is a file named problem2.php. It doesn't have much in it to start. There are two HTML comments in the file which direct you where to place a bit of server side logic.
Include a header file in the problem2.php file. There is an external file named header.html which contains an HTML fragment. Include this file in the main problem2.php file using PHP.
Echo the current day and date to the page when the page is viewed. The format for the date is given in the following screenshot. You will have to research the correct syntax for the date() function from the PHP Documentation
For this problem, you will create a Contact page, and add an HTML form to it. You will also create a new PHP script to echo the form contents.
You should create a folder holding your files, and zip it up for submission. Name your folder and zip file something descriptive like Your-Name-HW5.zip. Please make a folder with your files in it, and zip up the folder. Do not select all the files and zip them up. Your name is not Mark Fischer (that's my name!). :)
Homeworks Zip files will be submitted to D2L, in the "Assignment 5" dropbox.
You must also have the following pages available on your class VM