We strictly suggest all job seeker never pay any sort of money to any employer who posted job here. You can leave your reviews at employer profile sharing your experience and if anyone asks money than can report to us.

X

Discounts

Combat Covid-19 Lockdown 100% Off !!
Valid for First 50 Orders. 22 Sold- HURRY !!

PHP Interview Questions for Freshers

PHP Interview Questions for Freshers

In this article of PHP interview questions we are providing you some frequently asked PHP Interview Questions which will help you to win interview session easily.

1. Who is the father of PHP ?

Rasmus Lerdorf is known as the father of PHP.

2. What are the method available in form submitting?

GET and POST

3. What is the difference between $name and $$name?

$name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.

4- How can we get the browser properties using PHP?

<?php echo $_SERVER[‘HTTP_USER_AGENT’].”\n\n”; $browser=get_browser(null,true); print_r($browser); ?>

5. What Is a Session?

A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.

6. How can we register the variables into a session?

<?php session_register($ur_session_var); ?>

7. How many ways we can pass the variable through the navigation between the pages?

Register the variable into the session Pass the variable as a cookie Pass the variable as part of the URL

8. How can we know the total number of elements of Array?

sizeof($array_var) count($array_var)

9. How can we create a database using php?

mysql_create_db();

10. What is the functionality of the function strstr and stristr?

strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. For example:strstr("user@example.com","@") will return "@example.com". stristr() is idential to strstr() except that it is case insensitive.

11. What are encryption functions in PHP?

CRYPT(), MD5()

12. How to store the uploaded file to the final location?

move_uploaded_file( string filename, string destination)

13. Explain mysql_error()

The mysql_error() message will tell us what was wrong with our query, similar to the message we would receive at the MySQL console.

14. What is Constructors and Destructors?

CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used. DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.

15. What are the differences between Get and post methods.

There are some defference between GET and POST method 1. GET Method have some limit like only 2Kb data able to send for request but in POST method unlimited data can we send 2. when we use GET method requested data show in url but Not in POST method so POST method is good for send sensetive request

16. What are the differences between require and include?

Both include and require used to include a file but when included file not found Include send Warning where as Require send Fatal Error.

17. What is use of header() function in php ?

The header() function sends a raw HTTP header to a client.We can use herder() function for redirection of pages. It is important to notice that header() must be called before any actual output is seen.

18. List out the predefined classes in PHP?

Directory stdClass __PHP_Incomplete_Class exception php_user_filter

19. What type of inheritance that PHP supports?

In PHP an extended class is always dependent on a single base class,that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.

20. How do you define a constant?

Constants in PHP are defined using define() directive, like define("MYCONSTANT", 100);

21. How do you pass a variable by value in PHP?

Just like in C++, put an ampersand in front of it, like $a = &$b;

22. What does a special set of tags <?= and ?> do in PHP?

The output is displayed directly to the browser.

23. How do you call a constructor for a parent class?

parent::constructor($value)

24. What’s the special meaning of __sleep and __wakeup?

__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

25. What is the difference between PHP and JavaScript?

javascript is a client side scripting language, so javascript can make popups and other things happens on someone’s PC. While PHP is server side scripting language so it does every stuff with the server.

26. What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system. unset() makes a variable undefined.

27. How many ways can we get the value of current session id?

session_id() returns the session id for the current session.

28. for image work which library?

we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.

29. How can we get second of the current time using date function?

$second = date(“s”);

30. What are the Formatting and Printing Strings available in PHP?

printf()- Displays a formatted string sprintf()-Saves a formatted string in a variable fprintf() -Prints a formatted string to a file number_format()-Formats numbers as strings

31. How can we find the number of rows in a result set using PHP?

$result = mysql_query($sql, $db_link); $num_rows = mysql_num_rows($result); echo "$num_rows rows found";