php questions and answers for exams set A

 php questions and answers for exams

                                                                              
very short answer type questions

 1.)PHP stands for HYPERTEXT PREPROCESSOR.

2)Define PHP?
Ans. PHP is a web server side scripting language. PHP scripts are executed at web server. Their output which is pure HTML is returned to the requesting browser.

3.) Define Homepage?
Ans. A homepage is a web page that serer as the starting point of website. It is the default webpage that loads when you visit a web address that only contains domain name.

4.) Define Array?
Ans. An array is a data structure that contains a group of elements. Typically these elements are all of the same data type ,such as an integer or string.

5.) What is the use of “print” statement in php?
Ans.It is used to output data to screen. but difference is that it has a return value of 1 so it can be used in expression it can take one argument.

6.) What is the use of ”echo” statement in php?
Ans. It is also used to output data to the screen but the difference that it has no return value it can take multiple parameters

7.) What is the use of strops() function in PHP?
Ans. It is used for finding a substring within a string
Syntax:-
Strops($haystack,$needle,$offset)
Eg:-
<? php
$name=”mathew”;
Echo strpos ($name,”na”);
Echo strops ($name,”hew”);
Echo strops($name,”m”);
?>

8.) Define SQL?
Ans. Sql stands for structured query language .sql is used to communicate with a database. It is the standard language for relational database management system.

9.)Define constant?
Ans. A constant like variable is a temporary placeholder in memory that holds a value .its value never changes.

x.) What is the use of var_dump() function in PHP?
Ans. The var_dump function display structured information about variables/expressions including its type and value.

11.)what is the use of count() function in PHP?
Ans. The count() function is used to count elements of an array or the properties of an object
Syntax:-
Count (array-name, mode)

12.) How to retrieve a cookie value?
Ans. A cookie is often used to identify a user . A cookie is a small file that the server embeds on the user’s computer
For retrieving cooking eg  is—
The following example retrieve a cookie named “user ” with the value”johndoe”.The  cookie will  expire after 30 days
(86400*30).
Eg:-
<?php
$cookie_name=”user”;
$cookie_value=”john  doe”;
Setcookie($cookie­_name,$cookie_value,time()+(86400*30),”/”a
?>
The”/” means that the cookie is available in entire website

13.) Define break statement?
Ans. Break statement means it is encountered inside a loop the loop is immediately terminated and the program control resumes at the next statement following the loop.

14.) Define primary key?
Ans. A primary key is special relational database table column designated to uniquely identify all table records. It must contain a unique value for each row of data .it cannot contain null value.

15.)What is the purpose of  session variable in php?
Ans. When we work with an application we open it do some changes, and than we close it this is much like a session .the computer knows who we are. It knows when we start the application and when we end. but on internet there is one problem  the web server does not known who we are or what we do bcoz the http address doesn't maintain state. This problem is solved by session variable. Session variable stores the user information to be used across multiple pages.

16.)Write down the command for creating a mysql connection?
Ans. command for creating connection is:
$conn=myli_connect($servername,$username,$password);

17.)Define authorization?
Ans. Authorization is the process of giving someone permission to do or have something. In multi user computer system a system administrator  defines for the system which user are allowed access to the system and what privilege for use.

  
18.)What is an auto incremented field?
Ans. Auto increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted .

19.) Define the term loop?
Ans. A loop can be thought of as something that is wrapped around the php code special to make it happen again and again.
there are three types of loops-
*for loop
*while loop
*do-while loop

20.)what are string variables?
Ans .like numeric variable ,string variable can have labels and missing value declaration although missing string values cannot be longer than 8 character. string can be up to 32767 character long.

21.)How the php script block is initiated?
Ans.
<?php
             ____
             ____
        ?>
22.)What is command for setting cookie in php?
Ans.set_cookie (name,value,expire,path,domain,secure,http only);
only the name parameter is required, all other parameters are optional.

23.)Define API library?
Ans. application programming is a set of subroutine definition ,protocol, and tools for building application software. A good APL library makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer.

24.)What is the use of sql?
Ans. Sql is used to communicate with database.sql statements are used to perform tasks such  as update data on a database or retrieve data   from a database.

25.)Define multidimensional array?
Ans. A multidimensional array is an array containing one or more arrays.

26.)What is comment?
Ans. comments in php are similar to comments that are used in html. The php comment syntax always begins with a special character sequence and all text that appear between the start of the comment and end will be ignored.
there are two types of comments.
(i)single line comment("//"or"#")     
(ii)multiple line comment("/*"or"*/") 

27.) how can we declare a constant?
Ans. Syntax:-
  Define (name,value,case-insensitive)
  Name: specifies the name of constant
  Value: specifies the value of the constant
  Case-Insensitive: Specifies Whether the Constant name should be case –insensitive.
Eg:-<?php
Define(“GREETING”,”Welcom to W3Schools.com!”);
Echo GREETING;
?>

28.) What is returning value in PHP? Give examples.
Ans: A function can return a value using the return statement in conjunction with a value or object . Return stops the execution of the function and sends the value back to the calling code.
Eg:-<?php
     Function Sum($x,$y)
{
 $z=$x+$y;
return $z;
}
Echo “5+10=”.Sum((5,10).”<br>”;
Echo”7+13=”.Sum(7,13).”<br>”;
Echo”2+4=” Sum(2,4);                                                                                                              ?>
29.) How can we create user login?
Ans: Steps to create user :
1) Implementing user authentication mechanism
2) Building the registration system
3) Creating the config file
4) Creating the registration form
30.) Define PHP mail?
Ans: Syntax: mail(to subject, message, headers, parameters);

31.) Write the syntax of for loop?
Ans: Syntax: for(intialization;conditional;increment/decrement)
{
Code to executed;
}

32.) What is client server design?
Ans: The client server model ios the distributed application structure that partition tasks or workloads between the provides of a resource or service called servers and service

33.) What do you mean by variable function?
Ans:  Variable functions are those functions that wont with language constructs such as echo ,print, unset (),empty() Include, require and the like. PHP support the concept of variable functions. this means that if a variable name has parenthesis appended it , PHP will look for a function with the same name as whatever the variables evaluates to and will attempts to execute it.

34.) What is use of isset() funcation?
Ans: The isset() function is used to check wheather a variable is set or not. If a variable is already unset with unset() function, it will no longer be set. The issest() function return false if testing variable contain a Null value.
Syntax: isset(Variable1, Variable2…)

35.) What is the difference between array and function?
Ans:  Array:-
i) An array is a block of memory.
      ii) Array are of three types-
      * Indexed
      * Associative
      * Multi-dimensional
      Function:-
i) A function is a set of lines code.
ii) Functions are of two types-
* user-defined functions
* built-in functions

36.) What is PHP.INI file?
Ans: It is the default configuration file for running applications that require PHP . It is used to control variables such as upload sizes file time out and resource limits.

37.) Who is the father of PHP?
Ans: “Rasmuslerdorf” is the father or PHP.

38.) Which function is used to determine the length of array?
Ans: int length() function is used to determine the length of array.

39.) What is password element?
Ans: It provide a way for the user to securely enter a password. The element is presented as a one-line plain text editor control  in which the text is obscured so that it can not be read, usually by replacing each character with a symbol such as the asterisk (“*”) or a dot (“.”).

40.) Define Web Browser?
Ans: A web browser is a software application for retrieving, presenting and travelling information resource on the world wide web.

41.) What is database?
Ans: A database is a collection of information that is organized so that it can be easily accessed managed and update. Data is organized into rows, columns and tables, and it is indexed to make it easier to find relevant information

42.) Name any two built in function used in PHP?
Ans: * include()
     *header()

43.) Define PHP tags?
Ans: The PHP syntax is a set of rules that define how a program should be written. A set of tags are used to mark the beginning and end of a block of code in between which any amount of in between which any amount code can be written.

44.) What is Mysql?
Ans: Mysql is an open source relational database management system based on structured query language Xamp/Wamp is a web development platform that uses Linux as the operating system, Apache as the web server, Mysql as the relational database management system.

45.) How we start the PHP scripting block?
Ans: <?php
?>

46.) What is the use of concatenation operator?
Ans: Concatenation operator is used to concatenate two expressions that evaluate to character datatv type or to numeric data type.

47.) What is strlen() function?
Ans: The strlen() function returns the length of a string.
Syntax: Strlen (string)
Eg:-<?php
      Echo strlen (“hello world”);
?>

48.) Write four arithmetic operator?
Ans: The basic arithmetic operation are addition, subtraction, multiplication and division .

49.) What is post increment operator?
Ans: Post increment operator: The increment numbers and strings. Arrays , objects are not effected.
For example : $a++
               Returns $a then increments the $a by one

50.) Define associative array ?
Ans: In associative array the keys assigned to values can be arbitrary and user defined strings in the following example the array uses keys instead of index number .
Eg: $ages = array (“peter”=>22,”clerk”=>32,”john”=>28);

51.) Write a syntax to delete data from a database ?
Ans: Syntax to delete data from a database:
      Delete from table_name
      Where condition;

52.) Define  php form validation ?
Ans: validation means check the input submitted by the user. There are two types of validations are available in php. There are as follows-
i) client –side validation
ii) server-side validation

53.) Define Get variable?
Ans: Get variable contains the same initial information but is not a super global $_Get are different variables and that php handles them as such.
Eg: <?php
    Echo hello.html special char ($ Get[“name”]);
    ?>

54.) Define mode of file handling?
Ans: file handling is an important part of any web application. You can often need to open and process a file for different tasks
Php manipulating files :php has several functions for creating, reading , uploading and editing files.

55.) What are the loop statements?
Ans: loops in php are used to execute the same block of code a specified number of times. Php support the four loop types.
i) for
ii) while
iii) do-while
iv) for each