You are on page 1of 4

Practice

1) Check that you have PHP and Apache24 in your C drive.


2) Open your cmd.
3) cd to directory Apache24/bin
4) To install Apache, you type: httpd –k install
5) Then type: (make sure to close all the apps that use port 8080
such as vpn…)
httpd –k start
httpd –k restart
6) go to your browser and type: localhost:8080
7) If you see a long table of information, it means your server is
up running.
8) Now open the file:

C:/Apache24/htdocs/New Text Document.php

(use Aptana or notepad)


9) You can write your code in this file, then run the script by
going to your browser and typing: localhost:8080 , you will
see the results from your script there.
Today we are going to implement some basic
algorithms in PHP,

1)Write a PHP script to check if an integer is odd or even.

Answer:

<?php
$a=5;
if ($a%2==0)
{
echo “ This number is even”;
}
else
{
echo “ This number is odd”;
}
?>
2)Write a PHP script to Swap Two Variables3
3)Write a PHP script to Convert Kilometers to Miles
m=kilo * 0.621371
4)Write a PHP script to Check Vowel or consonant
5)Write a PHP script to Check Positive or Negative Using
if...else
6)Write a PHP script to initialize a variable and then
increment its value by 3.
7)Write a PHP program to check two given integers
whether either of them is in the range 100..200
inclusive. 
Sample Input:
100,199
250,300
105, 190
8)Write a PHP code for conversion from the Dollars-to-
Euros (Exchange rate 1 USD=0.8467 Euro).
9)Write a PHP script that accepts a temperature value in
Celsius (C) through a web form and converts it to the
Fahrenheit (F) scale. The conversion formula to use is:

F = (9/5) * C + 32.

You might also like