0% found this document useful (0 votes)
26 views

PHP Assignments (Ch4-8)

The document contains programming assignments on topics like creating PHP pages to display multiplication tables and prime numbers, creating HTML tables using PHP, representing directory structures using arrays in PHP, and defining a PHP class for a basic calculator.

Uploaded by

kellyelly555
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

PHP Assignments (Ch4-8)

The document contains programming assignments on topics like creating PHP pages to display multiplication tables and prime numbers, creating HTML tables using PHP, representing directory structures using arrays in PHP, and defining a PHP class for a basic calculator.

Uploaded by

kellyelly555
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignments (Chapter 4)

1. Create a PHP page (multiplication_table.php) that displays all multiplications of integers


from 1 * 1 to 9 * 9 in the table format like shown below. The grayed cell should be <th>
tag. You can also define CSS to make these <th> tags have gray background.

2. Create a PHP page (prime.php) that displays all “prime numbers” between 1 and 100 like
shown below. A prime number is the number that cannot be divided into multiplication of
smaller integers.
(Expected output)

1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97
Assignments (Chapter 6)

1. Write PHP code that receives the values of rows and cols and outputs a HTML table
depending upon the received values ( rows and cols ).

2. Below is a part of directory structure in Linux server. Create a PHP page that creates an
array ($c) to store this structure. You should also show the content of the array by using
print_r function.

Assignments (Chapter 7)

1. Create a PHP page (Chapter 6 Assignment2.php) that has a function to display the content
of given array that contains Linux tree directory structure (variable) like you have created
in Exercise5-3. The function should display the content by using HTML <div> tag with
CSS margin-left like shown below.

div { margin-left:
10mm; }
/ <div>/
etc <div>etc
apache2
<div>apache2
conf.d
<div>conf.d</div>
<div> tags
vhost.d
<div>vhost.d</div>
php5 </div>
<div>php5</div>
bin </div>
<div>bin</div>

</div>
Assignments (Chapter 8)

1. Create a PHP page that defines a class to perform calculator that supports +, -, * and /
operation. The number can be given as the complete number (like “3254”), not as the
numeric key sequence (like “3”, “2”, “5”, “4”)
• (Hint) Supporting following methods are enough.
• $obj->add($number); // Add $number to internal buffer
• $obj->subtract($number); // Subtract $number from internal buffer
• $obj->multiply($number); // Multiply $number to internal buffer
• $obj->divide($number); // Divide internal buffer by $number
• $obj->clear(); // Clear internal buffer to 0
• $obj->show(); // Echo the internal buffer
• Once completed, try calculating the followings (inside the same PHP page).
• Add 10 (to the internal buffer) ->Show internal buffer
• Subtract 3 -> Show internal buffer
• Multiply by -5 -> Show internal buffer
• Divide by 4 -> Show internal buffer
• Clear internal buffer -> Show internal buffer

You might also like