You are on page 1of 7

2 marks

 What is PHP?
 What is difference between “echo” and “print”?
 What is the use of isset ( ) function?
 Which are the methods to submit form?
 Explain setcookie ( ) in PHP.
 What is $-SESSION in PHP?
 Explain split ( ) function in PHP.

 What does PEAR stands for? -PEAR is short for "PHP


Extension and Application Repository" The purpose of PEAR
is to provide:

 A structured library of open-source code for PHP


users
 A system for code distribution and package
maintenance
 A standard style for code written in PHP,
 The PHP Extension Community Library (PECL),
 A web site, mailing lists and download mirrors to
support the PHP/PEAR community

 What is the use of print_r( )
 What does the unset ( ) function mean?
 List the types of array.
 What are different arithmatic operators in PHP?
 What is abstract class in PHP?
 Define sticky form. -A sticky form is simply a standard
HTML form that remembers how you filled it out. This is a
particularly nice feature for end users, especially if you are
requiring them to resubmit a form.
 What is validation?
 What is use of array-slice () in PHP?
 What are the databases supported by PHP?
 what is the use of session?
 Which attribute is used for multiple selections in select tag?
 What is the purpose of break statement?
 What is the purpose of switch statement?

4 marks

 What are the different types of PHP variables?


 What is the difference between GET and POST method?
 Explain if ...... then ...... else in PHP.
 Explain cookies in PHP
 Explain any two string functions in PHP.
 What are superglobals in PHP?

Some predefined variables in PHP are "superglobals", which means that they
are always accessible, regardless of scope - and you can access them from
any function, class or file without having to do anything special.

The PHP superglobal variables are:

 $GLOBALS
 $_SERVER
 $_REQUEST
 $_POST
 $_GET
 $_FILES
 $_ENV
 $_COOKIE
 $_SESSION

$GLOBALS : It is a superglobal variable which is used to access global


variables from anywhere in the PHP script. PHP stores all the global
variables in array $GLOBALS[] where index holds the global variable
name, which can be accessed.

$_SERVER : It is a PHP super global variable that stores the


information about headers, paths and script locations. Some of these
elements are used to get the information from the superglobal
variable $_SERVER.

$_REQUEST : It is a superglobal variable which is used to collect the


data after submitting a HTML form. $_REQUEST is not used mostly,
because $_POST and $_GET perform the same task and are widely
used.

$_POST : It is a super global variable used to collect data from the


HTML form after submitting it. When form uses method post to
transfer data, the data is not visible in the query string, because of
which security levels are maintained in this method.

$_GET : $_GET is a super global variable used to collect data from the
HTML form after submitting it. When form uses method get to
transfer data, the data is visible in the query string, therefore the
values are not hidden. $_GET super global array variable stores the
values that come in the URL.

 Write the functions performed by a web browser.

The get_browser() function in PHP is an inbuilt function that is used to tell


the user about the browser’s capabilities. This function looks up the user’s
browscap.ini file and returns the capabilities of the user’s browser. The
user_agent and the return_array are passed as parameters to the
get_browser() function and it returns an object or an array with information
about the user’s browser on success, or FALSE on failure.

Syntax:
get_browser(user_agent, return_array)

Parameters Used: The get_browser() function in PHP accepts two


parameters:
 user_agent: It is an optional parameter that specifies the name of
an HTTP user agent. Default is the value of $HTTP_USER_AGENT.
 return_array: It is an optional parameter that returns an array
instead of an object if it is set to True.
Return Value: It returns an object or an array with information about the
user’s browser on success, or FALSE on failure.
Exceptions:
 The user_agent parameter can be bypassed with a NULL value.
 The cookies value simply means that the browser itself is capable
of accepting cookies and does not mean the user has enabled the
browser to accept cookies or not.
 In order for this function to work the browscap configuration
setting in php.ini must point to the correct location of the
browscap.ini file on your system.
Approach: For checking the browser capability of the users’ system &
acknowledging them accordingly, we will be using the get_browser()
function that contains the 2 parameters namely, user_agent that will be
utilized to specify the name of an HTTP user agent, & the second parameter
is return_array that will return an array instead of an object if the value is
set to true.

 Write a code in PHP which accepts two strings from user


and displays them after concatenation.
 Write a PHP function to calculate factorial of a number using
recursion.
 Write a PHP program to print greatest number among given
3 numbers.
 Explain self processing form using example.
PHP self-processing form

A common use of PHP_SELF variable is in the action field of the <form> tag.
The action field of the FORM instructs where to submit the form data when
the user presses the “submit” button. It is common to have the same PHP
page as the handler for the form as well.
However, if you provide the name of the file in the action field, in case you
happened to rename the file, you need to update the action field as well; or
your forms will stop working.
Using PHP_SELF variable you can write more generic code which can be used
on any page and you do not need to edit the action field.
Consider, you have a file called form-action.php and want to load the same
page after the form is submitted. The usual form code will be:

<form method="post" action="form-action.php" >


We can use the PHP_SELF variable instead of “form-action.php”. The code
becomes:
<form name="form1" method="post" action="<?php echo
$_SERVER['PHP_SELF']; ?>" >

The complete code of “form-action.php”

Here is the combined code, that contains both the form and the PHP script.

<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
echo "User Has submitted the form and entered this name : <b> $name
</b>";
echo "<br>You can use the following form again to enter a new name.";
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="name"><br>
<input type="submit" name="submit" value="Submit Form"><br>
</form>

 How inheritance is implemented in PHP? Explain using


example.
 Write a menu driven program in PHP to display arithmatic
operations.
 Write a PHP program to generate random password.

<?php

function generate_pw() {

// Set random length for password

$password_length = rand(8, 16);

$pw = '';

for($i = 0; $i < $password_length; $i++) {

$pw .= chr(rand(32, 126));

return $pw;

?>

 Write a PHP program to create login page and welcome user


on next page.
 Explain multidimensional array in PHP with example.
 Write a PHP Program to check whether given year is leap
year or not (use if else)
 Write a PHP script to define an interface which has methods
area () volume (). Define constant PI. Create a class cylinder
which implements this interface and calculate area and
volume
 What are the built in functions of string?
 Write a PHP program to reverse an array
 What is variable in PHP? Explain its scope with example.
 What is the difference between for and for each in PHP?
 Write a PHP Program to display reverse of a string.
 How to create cookies? Give an example.
 Explain passing values by reference with an example
 What is array? Explain different types of array in PHP.
 What is the difference between a while loop and do while
loop in PHP.
 Write a PHP program to find the sum of digit of a given
number.
 Write a PHP program to use multiple checkbox to select
hobbies
 List various MYSQL Queries with their Syntax.
 What is class and how to create object of a class? Give an
example.
 What is abstract class?
 Explain working with radio buttons with an example.

3 marks

 Form and Form elements


 Logical operators in PHP
 Validation in PHP
 Explain advantages of PHP built in functions
 Explain GET Method
 List Advantages of PHP.
 Attributes of form tag.
 What is constructor and destructor?
 Write a note on Cookie and Sesions in PHP.

You might also like