Sunday, 1 September 2013

40 - PHP Interview Questions

1. What is the full form of PHP?
Ans. Hypertext Preprocessor.

2. What is PHP?
Ans. PHP is a server-side scripting language used for making web applications.

3. Who is the father of PHP?
Ans. Rasmus Lerdorf

4. What does PEAR stand for?
Ans. PEAR means “PHP Extension and Application Repository”. it extends PHP and provides a higher level of programming for web developers.

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

6. How to include a file to a PHP page?
Ans. Using include() or require() function.

7. Can you tell me the difference between include and require functions?
Ans. If the file is not found require() function will give error and stop execution while include() function will give a warning and script execution will not be interrupted.

8. How many times is it possible to use an include function in a PHP page?
Ans. We can use include function multiple times in a PHP page.

9. What is the difference between require() and require_once()?
Ans. require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

10. What is the basic syntax of PHP?
Ans. <? php ?> A PHP scripting block can be placed anywhere in the document.

11. What is the current version of PHP?
Ans. 7.2

12. What is Default Session time in PHP?
Ans. It is 1440 seconds or 24 minutes.

13. What are the methods available in form submitting?
Ans. GET and POST.

14. What are the different functions in sorting an array?
Ans. asort()
arsort()
ksort()
krsort()
uksort()
sort()
natsort()
rsort()

15. What is PHP’s configuration file called?
Ans. php.ini

16. Which function would you use to merge two arrays?
Ans. You can merge arrays with the array_merge() function.

17. How can we get second of the current time using date function?
Ans. What is PHP’s configuration file called?
<?php
$second = date(“s”);
? >


18. How can we submit a form without a submit button?
Ans. Javascript submit() function is used to submit form without submit button.
document.formname.submit().

19. What is a Session in PHP?
Ans. PHP session stores user information for a particular time.

20. How do we start a PHP session?
Ans. Using session_start();

21. What is the default execution time set in set_time_limit()?
Ans. 30 sec.

22. How to count elements of an array in PHP?
Ans. using sizeof() method or using count() method.

23. How can we destroy the session variable?
Ans. using session_destroy().

24. Which programming language does PHP reassemble?

Ans. C and Perl

25. Is multiple inheritance supported by PHP?

Ans. No, PHP supports single inheritance.

26. How to remove duplicate values from an array?

Ans using array_unique() function.

27. How to register the session in PHP?

Ans. <?php
session_register($ur_session_var);
?>

28. Which methods are used to count the total number of elements in an array?
Ans. sizeof() and count() function.

29. How to declare an array in PHP?

Ans. var $aaray=array('Ball','Bat','Stamp');

30. How to set cookies in PHP?

Ans. Setcookie("User","Sapna",time()+3600);

31. How to retrieve cookie in PHP?

Ans. echo $_COOKIE["User"];

32. How can we get the ip address of the client?

Ans. $_SERVER["REMOTE_ADDR"]

33. How to redirect a page in PHP?

Ans. header("Location:index.php");

34. Is multiple inheritance supported by PHP?

Ans. No, only single inheritance is supported by PHP.

35. Which library is used to execute image functions?

Ans. GD Library

36. How to stop the execution of the PHP script?

Ans. exit() function is used to stop the execution of the PHP script.

37. What is the use of the unset() function?

Ans. unset() function sets variable to "undefined".

38. What is the use of the "ksort" in PHP?

Ans. "ksort" is used to sort the array by key in reverse order.

39. Which function is used to check that the variable is number or not?

Ans. is_numeric()

40. How to define a constant in PHP?

Ans. define() function is used to define the constant.

No comments:

Post a Comment

Thanks

SQL server tricky questions