PHP Interview Questions And Answers

PHP Interview Questions And Answers

PHP Online Training1.What is the most convenient hashing method to be used to hash passwords?
Answer: It is preferable to use crypt() which natively supports several hashing algorithms or the function hash() which supports more variants than crypt() rather than using the common hashing algorithms such as md5, sha1 or sha256 because they are conceived to be fast. hence, hashing passwords with these algorithms can vulnerability.

2.What is the difference between the functions strstr() and stristr()?
Answer: The string function strstr(string allString, string occ) returns part of allString from the first occurrence of occ to the end of allString. This function is case-sensitive. stristr() is identical to strstr() except that it is case insensitive.

3.What is the goto statement useful for?
Answer: The goto statement can be placed to enable jumping inside the PHP program. The target is pointed by a label followed by a colon, and the instruction is specified as a goto statement followed by the desired target label.

4.What does the scope of variables means?
Answer: The scope of a variable is the context within which it is defined. For the most part all PHP variables only have a single scope. This single scope spans included and required files as well.

5.What should we do to be able to export data into an Excel file?
Answer: The most common and used way is to get data into a format supported by Excel. For example, it is possible to write a .csv file, to choose for example comma as separator between fields and then to open the file with Excel.

6.How can PHP and Javascript interact?
Answer: PHP and Javascript cannot directly interacts since PHP is a server side language and Javascript is a client side language. However we can exchange variables since PHP is able to generate Javascript code to be executed by the browser and it is possible to pass specific variables back to PHP via the URL.

7.How comparison of objects is done in PHP5?
Answer: We use the operator ‘==’ to test is two object are instanced from the same class and have same attributes and equal values. We can test if two object are refering to the same instance of the same class by the use of the identity operator ‘===’.

8.How can we submit a form without a submit button?
Answer: The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button.You can attach the document.formname.submit() method to onclick,onchange events of different inputs and perform the form submission. you can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites).

9.What are the features and advantages of object-oriented programming?
Answer: One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns.For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system.

10.What is the use of friend function?
Answer: Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class.

A friend declaration is essentially a prototype for a member function,but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match.

For Best PHP Online Training please visit http://www.srihithatechnologies.com

Save