Create and test php scripts that include arrays after


PHP: Arrays, Functions and Form processing

Overview

This lab walks you through using PHP to create simple applications. PHP is popular for many Web applications, so becoming comfortable with the syntax of PHP will help you diagnose and identify potential security issues. It is not envisioned you will become an expert in PHP from this course, but you will be able to create simple Web applications; and, in the near future of this course, analyze that code for security issues.

Learning Outcomes:

At the completion of the lab you should be able to:

1. Create and test PHP scripts that include Arrays
2. Create and test PHP scripts that include Functions
3. Create, and test PHP scripts to process HTML Forms
4. Compare and contrast session creating mechanisms in PHP

Lab Submission Requirements:

After completing this lab, you will submit a word (or PDF) document that meets all of the requirements in the description at the end of this document. In addition, your Web Application files should be submitted. You can submit multiple files in a zip file.

Virtual Machine Account Information

Your Virtual Machine has been preconfigured with all of the software you will need for this class. The default username and password are:

Username : umucsdev Password: umuc$d8v

Part 1 - Create and test PHP scripts that include Arrays

This exercise will walk through creating a PHP script that creates, uses and manipulates arrays. We will use the gedit text editor to create the PHP file in the Virtual Machine.

1. After launching the gedit text editor, create a new document and type or copy and paste the PHP code shown below:

2. As before, you can also run the PHP code directly from the shell prompt. To run from the shell prompt, open a shell prompt, change to the location of the ArraysDemo.php file and type:

php ArraysDemo.php

Running from the shell may provide some insight when you php Errors that prevent the cause the script to stop running prior to producing the HTML output.

Part 2 Create and test PHP scripts that include Functions

In this exercise we will create a PHP web page that uses both existing and user-defined PHP functions. Functions are used to help organize code into sub-units to allow for code reuse and reproducible results.

1. Copy and paste the following code into a file named FunctionsDemo.php in the /var/www/html/week4 folder on your Virtual Machine.

2. Launch your Firefox browser and run the Web application. Assuming you placed the file in the /var/www/html/week4 folder you can run this by typing the following URL on your Virtual machine: localhost/week4/FunctionsDemo.php.

3. Reviewing the code you should note the following:

a. Existing PHP functions can be used easily by calling the function name and any required parameters. For this example, sqrt(), deg2rad(), sin(), cos() and tan() existing functions were called.

b. PHP functions you create should be of the format.

https://www.dropbox.com/s/d9micawv81nihae/Lab_PHP_and_Web_Forms.rar?dl=0

Request for Solution File

Ask an Expert for Answer!!
PHP Web Programming: Create and test php scripts that include arrays after
Reference No:- TGS01487268

Expected delivery within 24 Hours