Monday 9 February 2015

100 TOP Freshers PHP Technical Interview Questions and Answers (Page 1)

Below are some important PHP interview questions which are asked in most MNC company interviews for beginners or professionals.

1. How can we submit a form without a submit button? | PHP Questions
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).

2. In how many ways we can retrieve the data in the result set of MySQL using PHP? | PHP Questions
You can do it by 4 Ways
1. mysql_fetch_row.
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc

3. What is the difference between mysql_fetch_object and mysql_fetch_array? | PHP Questions
mysql_fetch_object() is similar tomysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

4. What is the difference between $message and $$message? | PHP Questions
It is a classic example of PHP’s variable variables. take the following example.$message = “Mizan”;$$message = “is a moderator of PHPXperts.”;$message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan with the value “is a moderator of PHPXperts.” assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.

5. How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’ using regular expression of PHP? | PHP Questions
preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);
echo $found[1];

6. How can we create a database using PHP and MySQL? | PHP Questions
We can create MySQL database with the use of mysql_create_db(“Database Name”)

7. What are the differences between require and include, include_once and require_once? | PHP Questions
The include() statement includes and evaluates the specified file.The documentation below also applies to require(). The two constructs are identical in every way except how they handlefailure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missingfile to halt processing of the page.
include() does not behave this way, the script will continue regardless.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only differencebeing that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once() should be used in cases where the same file might be included and evaluated more than once during a particularexecution of a script, and
you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.

8. Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”? | PHP Questions
Yes we can use include() more than one time in any page though it is not a very good practice.

9. What are the different tables present in MySQL, which type of table is generated when we are creating a table in the following syntax:
create table employee (eno int(2),ename varchar(10)) ? | PHP Questions
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.

10. How can we encrypt the username and password using PHP? | PHP Questions
The functions in this section perform encryption and decryption, and compression and uncompression:
encryption decryption
AES_ENCRYT() AES_DECRYPT()
ENCODE() DECODE()
DES_ENCRYPT() DES_DECRYPT()
ENCRYPT() Not available
MD5() Not available
OLD_PASSWORD() Not available
PASSWORD() Not available
SHA() or SHA1() Not available
Not available UNCOMPRESSED_LENGTH()
More Questions & Answers :-
Page1  Page2  Page3  Page4  Page5  Page6  Page7  Page8  Page9  Page10

No comments:

Post a Comment