blog banner


1. How can we submit from without a submit button?

We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form.

2. What is the functionality of the function htmlentities?

htmlentities Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.


3. How can we get the properties (size, type, width, height) of an image using php image functions?

  • To know the Image type use exif_imagetype () function
  • To know the Image size use getimagesize () function
  • To know the image width use imagesx () function
  • To know the image height use imagesy() function


4. What is the maximum size of a file that can be uploaded using php and how can we change this?

You can change maximum size of a file set upload_max_filesize variable in php.ini file.

5. How can we increase the execution time of a php script?

Set max_execution_time variable in php.ini file to your desired time in second.

6. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

  • Mysql_fetch_array Fetch a result row as an associative array, a numeric array, or both.
  • mysql_fetch_object ( resource result ) Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows
  • mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.


7. Is PHP a case sensitive programming language?

PHP is a partially case sensitive programming language. We can use function names, class names in case insensitive manner.


8. What is mean by LAMP?

LAMP means combination of Linux, Apache, MySQL and PHP.

9. How do you get the user's ip address in PHP?

Using the server variable: $_SERVER['REMOTE_ADDR']

10. How do you make one way encryption for your passwords in PHP?

Using md5 function or sha1 function. md5 function generates a 32 bit encrypted character string for a particular password. At the time of registration we convert the user's password to an encrypted string with md5 and store in database, and then when user wants to log in again by entering the password s/he provided at the time of registering,  we verify it by passing the password provided by user at the time of log in through md5 and then by comparing it with already stored 32 bit encrypted password. As there is no de-cryption procedure for md5 is the reason why it is called one way encryption.

11. Echo vs. print statement.


  • echo() and print() are language constructs in PHP, both are used to output strings. The speed of both statements is almost the same.
  • echo() can take multiple expressions whereas print cannot take multiple expressions.
  • Print return true or false based on success or failure whereas echo doesn't return true or false


12. How can we know the number of days between two given dates using PHP?

The start date and end date can be first found as shown below:

$date1= strotime($start_date);
$date2= strotime($end_date);
$date_diff = (($date1)- ($date2)) / (60*60*24)

13. How to use HTTP Headers inside PHP? Write the statement through which it can be added?

HTTP headers can be used in PHP by redirection which is written as:


The headers can be added to HTTP response in PHP using the header(). The response headers are sent before any actual response being sent. The HTTP headers have to be sent before taking the output of any data. The statement above gets included at the top of the script.

14. Why PHP is also called as Scripting language?

PHP is basically a general purpose language, which is used to write scripts. Scripts are normal computer files that consist of instructions written in PHP language. It tells the computer to execute the file and print the output on the screen. PHP is used for webpages and to create websites, thus included as scripting language.


15. Why many companies are switching their current business language to PHP? Where PHP basically used?

PHP is rapidly gaining the popularity and many companies are switching their current language for this language. PHP is a server side scripting language. PHP executes the instructions on the server itself. Server is a computer where the web site is located. PHP is used to create dynamic pages and provides faster execution of the instructions.

16. What is the difference between PHP and JavaScript?

The difference lies with the execution of the languages. PHP is server side scripting language, which means that it can’t interact directly with the user. Whereas, JavaScript is client side scripting language, that is used to interact directly with the user.

17. How many different types of messages available in PHP?

1. Error message: is received when the script has some problem that is preventing it from running correctly. The message consists of the possible solution or identification of the problem. Ex: Parse error: occurs when there is something gets missed while writing the script.

2. Warning message: is received when the script find out some problem that doesn’t allow the script to run. These messages are not of very high priority but quite essential to show that there is something wrong with the script. 

18. Write a program to show the joining of two strings in PHP?

Two strings can be joined together by the use of a process called as concatenation. A dot (.) operator is used for this purpose. Example is as follows:

$string1 = _Hello_;
$string2 = _World!_;
$stringall = $string1.$string2;
echo $stringall;

19. What is the difference between array_merge and array_combine


It merges the elements of one or more than one array such that the value of one array appended at the end of first array. If the arrays have same strings key then the later value overrides the previous value for that key .


$array1 = array("course1" => "java","course2" => "sql");
$array2 = array(("course1" => "php","course3" => "html");
$result = array_merge($array1, $array2);




[course1] => php
[course2] => sql
[course3] => html



It creates a new array by using the key of one array as keys and using the value of other array as values.


$array1 = array("course1","course2");
$array2 = array(("php","html");
$new_array = array_combine($array1, $array2);




[course1] => php
[course2] => html


20. What is use of var_dump

var_dump() function is used to display structured information(type and value) about one or more variable.



Example :




output :


21. What is the difference between PHP4 and PHP5

There are some difference between PHP4 and PHP5 that are as following:-

1) In PHP5 abstract classes are used but not used in PHP4.

2) In PHP5 interfaces are used but not used in PHP4.

3) In PHP5 visibility are used but not used in PHP4.

4) In PHP5 magic methods are used but not uesd in PHP4.

5) In PHP5 typehinting are used but not used in PHP4.

6) In PHP5 cloning are used but not used in PHP4.

7) In PHP5 construtor are written as __construct keyword but in PHP4 are written as class name.

22. What is a .htacces file

.htaccess is a configuration file running on Apache server.These .htaccess file used to change the functionality and features of apache web server .

  • .htaccess file used for url rewrite .
  • .htaccess file used to make the site password protected.
  • .htaccess file can restrict some ip addresses ,so that on restricted ip adresses site will not open.


23. How to read the contents of a file in PHP


$fileName = 'instructions.txt';
$file = fopen(“instructions.txt”,”r”) or exit(“Unable to open the file!”) ;
While( ! feof($file) ) // feof()checks the end of file in php

echo fgets($file); // fgets() read a fileline by line in php

fclose($file); // fclose() used to close a file in php


24. How to read a file character by character


/*fgetc() function is used to read a file character by character.*/

While(!feof($file)) // feof()checks the end of file in php

echo fgetc($file); // fgetc() read a file character by character in PHP



25. Which function is used to remove HTML tags from data

Strip_tags() function is used to remove html tags.
Example :


$data = '<p>Web Development</p>' ;

echo $profession = strip_tags($data); // It will remove the <p> tag from output.


26. What is differnce between HTML and XHTML

1 : HTML stands for HyperText Markup Language and an application of SGML(Standard Gneralized Markup Language ).
Whereas XHTML (Extensible Hyper text Markup Language) is an application of XML .

2 :HTML permit the omission of certain tags and use attribute minimization whereas XHTML does not permit the omission of any tag .A XML document must be well formed ,means there must be an end tag for every start tag.

27. What is the reason behind selecting LAMP for web development

The main reason behind selecting LAMP is :

  • All are open sources and free to use.
  • The security of LINUX is much more than windows operating system.
  • The Apache server have better security and functionality compared to Apache .
  • MySql is a world wide open source database and enrich in functionality and security .
  • PHP is an open source and free to use.It is faster than any other scripting languages


28. How can we get all the properties of browser in PHP

We can get the browser properties in PHP by :




29. How to get the names of all included and required files for a particular page in PHP

The function get_included_files () function is used to get the names of all required and included files in a page . It returns an array with the names of included and required files in a page

30. What is end function in PHP

End function can set the pointer of an array to the last element of array.


$arr = array('name'=>'angel' ,'city'=>'delhi' ,'profession'=>'web developer');
$lastValue = end($arr);



web developer

31. How can we resolve maximum allocation time exceeds error

We can resolve these errors through php.ini file or through .htaccess file.

1. From php.ini file increase the max_execution_time =360 (or more according to need) and change memory_limit =128M (or more according to need)

2. From php file we can increase time by writing ini_set(‘max_execution_time’,360 ) at top of php page to increase the execution time. And to change memory_limit write ini_set(‘memory_limit ,128M )

3. From .htaccess file we ncrease time and memory by

<IfModule mod_php5>

php_value max_execution_time 360

php_value m emory_limit 128M

</ IfModule >

32. How can we get the first element of an array in php

We can get the first element of an array by the function current();

Example :


$arr = array('name'=>'angel','age'=>'23','city'=>'delhi','profession'=>'php developer');
$firstvalue = current($arr);




33. What is difference between strstr and stristr.

strstr and stristr both are used to search for the first occurrence of a string inside another string

Difference :

the strstr function is case sensitive and stristr is case insensitive.

Example : 


$email =;
$result = strstr($email , ‘@’); 


output :

34. How to find first array elements which are missing in second array.


$array1 = array("a" => "green", "red", "blue", "red");

$array2 = array("b" => "green", "yellow", "red");

$result = array_diff($array1, $array2);



35. what is headers already sent error , why we encounter this and how it can be resolved?

A web page is composed of two parts, the header and the body. An error is seen like something:
Warning: Cannot modify header information – headers already sent by (output started at /home/usr1/public_html/sent.php:42) in /home/usr1/public_html/includes/theme-header.php on line 12
Header is generated automatically containing information related to server, cookies. Sometimes programmers want to change some of the header values. For example, if the PHP if generating XML output, the Content-Type should be changed to reflect this. Another common example is in redirecting the user’s browser to a different web page using the Location header element.

The header must come first in the response from a web server and is separated from the body by one blank line. The reason this error occurs is that some part of the body of the web page has been sent to the user already when a request is made to set a header value. Because PHP simplifies many things for you, the problem may be hiding in plain site. Here are some guidelines for finding the problem:

1) Find the header () statement that is causing the problem. The error must be at or before this line.

2) Look for any statements that could send output to the user before this header statement. If you find one or more, change your code to move the header statement before them. Complex conditional statements may complicate the issue, but they may also help solve the problem. Consider a conditional expression at the top of the PHP script that determines the header value as early as possible and sets it there.

3) Make sure there is no white space outside of the PHP start and end tags. While a blank line before the <?php start tag may look innocent, when processed by PHP, it will turn into an echo statement printing out a blank line

36. What is PHP sessions default timeout.

The default session timeout is 24 minutes (1440 seconds),
however we can change this value by setting session.gc_maxlifetime() in php ini file.

37. How to refresh a page using HTML

To refresh the page using HTML we can use META to refresh the page or to redirect to other page after certain period of time.
To refresh the page we can use


<meta http-equiv="refresh" content="15">


Then the page will refresh after every 15 seconds.


To redirect to other url we can use below code.


<meta http-equiv="refresh" content="15" URL="target.html">


From the above code the page will refresh after 15 seconds, and new URL will be target.html

38. What is difference between var_dump and print_r


This function displays structured information about variables including its type,size and value

Example :





array(4) { ["a"]=> string(3) "red" ["b"]=> string(5) "green" ["c"]=> string(4) "blue" ["d"]=> string(6) "yellow" }


This function displays information about a variable in a human readbale format. Array will be presented in a format of key value






Array ( [a] => red [b] => green [c] => blue [d] => yellow )

Admin Team

0 Respond

Exam Questions
BLOG Posts
For study materials
Job Walk-In
Updates across India
Interview round
Interview or procedure
For study materials
Please LIKE our page to Get regular JOB WALK-IN UPDATES across India and STUDY MATERIALS on facebook news feed.