1.
Adds up Columns and Rows of a Given Table
AIM:
To write a PHP program that calculates the sum of each row and each
column in a given table.
ALGORITHM:
1. Start
2. Create a 2D array to represent the table
3. Loop through each row to calculate row sums
4. Loop through each column to calculate column sums
5. Display the sums
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
2. Sum of First n Prime Numbers
AIM:
To compute the sum of the first n prime numbers using PHP.
ALGORITHM:
1. Start
2. Set a counter and initialize a sum variable
3. Loop through numbers and check for primality
4. If prime, add to sum and increment count
5. Repeat until n primes are found
6. Print the sum
7. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
8. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
9. Select the respective program name to run
[Link]
3. Validate an Email Address
AIM:
To write a PHP program to check if an email address is valid.
ALGORITHM:
1. Start
2. Take the email input
3. Use PHP's filter_var() function with FILTER_VALIDATE_EMAIL
4. Print whether the email is valid or not
5. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
6. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
7. Select the respective program name to run
8. Stop
4. Convert Number in Words to Digits
AIM:
To convert a number written in words to its numeric form
ALGORITHM:
1. Start
2. Accept the input in words
3. Create a mapping of words to digits
4. Parse the words and compute the numeric value
5. Print the number
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
AIM:
To delay PHP script execution for a given number of seconds.
ALGORITHM:
1. Start
2. Accept input seconds
3. Use PHP’s sleep() function
4. Continue script after delay
5. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
6. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
7. Select the respective program name to run
8. Stop
6. Change Colour of First Character of a Word
AIM:
To change the color of the first character of a given word using HTML/CSS
in PHP.
ALGORITHM:
1. Start
2. Accept or define a word
3. Separate the first character
4. Wrap the first character in a span with color style
5. Concatenate and print
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
7. Multiplication Table of a Number
AIM:
To print the multiplication table of a given number.
ALGORITHM:
1. Start
2. Accept or define the number
3. Loop from 1 to 10
4. Multiply the number with loop index
5. Print the result
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
RESULT: Thus the multiplication table for a given number displayed
successfully.
8. Calculate Factorial of a Number
AIM:
To calculate the factorial of a number.
ALGORITHM:
1. Start
2. Accept the number
3. Initialize factorial as 1
4. Multiply factorial by each number up to n
5. Print result
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
AIM:
To read contents of a file, reverse it, and write to a new file.
ALGORITHM:
1. Start
2. Open the input file
3. Read contents
4. Reverse the string
5. Open/create output file
6. Write reversed content
7. Close files
8. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
9. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
[Link] the respective program name to run
[Link]
RESULT: Thus the contents of a file are reversed successfully
10. Rename .txt Files to .xtx
AIM:
To rename all .txt files in a directory to .xtx.
ALGORITHM:
1. Start
2. Open current directory
3. Loop through files
4. If file ends with .txt, rename it to .xtx
5. Close directory
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
RESULT: Thus files in the current directory renamed with extension .txt
to extension .xtx successfully.
AIM:
To list files in the current directory sorted by last modified time.
ALGORITHM:
1. Start
2. Read all files in the directory
3. Use filemtime() to get modification time
4. Sort the array by time
5. Print file names
6. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
7. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
8. Select the respective program name to run
9. Stop
RESULT: Thus the file list sorted by lastmodification time using
filemtime() successfully.
AIM:
To create a mark sheet management system with options to insert,
delete, and modify student records.
ALGORITHM:
1. Start
2. Connect to database
3. Create table if not exists
4. Implement form for insert, delete, and update
5. Process form inputs using PHP and SQL queries
6. Display data
7. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
8. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
9. Select the respective program name to run
[Link]
RESULT: Thus the student marksheet database system created
successfully.
AIM:
To retrieve and print email addresses from an XML file.
ALGORITHM:
1. Start
2. Load [Link] using simplexml_load_file()
3. Traverse XML structure
4. Extract and print email addresses
5. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
6. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
7. Select the respective program name to run
8. Stop
RESULT: Thus the script Prints all email addresses found in XML file
AIM:
To retrieve the value John from [Link] using three different DOM
methods.
ALGORITHM:
1. Start
2. Load XML using DOMDocument
3. Retrieve John using:
o getElementsByTagName()
o XPath
o Traversing childNodes
4. Print result
5. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
6. Open the browser and type as /localhost/demo in the address
[Link] the programs in the demo folder are listed.
7. Select the respective program name to run
8. Stop
RESULT: Thus the script Retrieves "John" Using DOM in 3 Ways
successfully.
AIM:
To retrieve records from a MySQL table and output them as XML using the
DOM.
ALGORITHM:
1. Start
2. Connect to MySQL
3. Run SELECT query
4. Create DOMDocument object
5. Loop through records and add XML nodes
6. Save or print XML output
7. Save the program with .php extension in xammp➔htdocs➔create a
demo folder and save the php file in that location
8. Open the browser and type as /localhost/demo in the address bar.
All the programs in the demo folder are listed.
9. Select the respective program name to run
[Link]
RESULT: Thus the script retrieve records from a MySQL table and output
them as XML using the DOM successfully.