In this tutorial, We are sharing some interview questions those are mostly asked into the interview. In some interviews, interviewer will ask you question about PHP and HTML but in some cases, they will ask you to perform in practical task. they will give you some task to do.

PHP - Interview Question

Q1. Can we submit a form without using submit button?
Answer.

Yes, Using JavaScript
The main reason behind this to use submit() function in JavaScript for submitting the form value without using to click submit button. we can also attach the document.Formname.submit() function to OnClick and events and execute the form submission. we can also use some timer function by that after the given time form will be submit automatically.

Q2. How many types we can retrieve or fetch the data into the table or result set in PhpMyAdmin?
Answer. There are 4 types by that we can fetch or retrieve data from database.
1. mysql_fetch_row
2. mysql_fetch_object
3. mysql_fetch_array
4. mysql_fetch_assoc

Q3. Difference between mysql_fetch_array  and mysql_fetch_object?
Answer.

There are only one difference in both of them - Instead of an array, an object is returned. that means we can access the data with the help of field names, and not with the property names.

Q4. How to Create Database and its connectivity?
Answer.

We can Create MySQL database with simple Query like: -
mysql_create_db("your_database_name");

And for connectivity -
mysql_select_db("your_db_name");

Q5. Differences Between require and include, include_once and require_once?
Answer.

Require and Include both are used for including file into file. but there are difference between them requires show the Fatal Error when file do not exists. but with include case, PHP script or file will run smoothly with out any error. Include shows the warning message only and script will continue regardless and require show the Fatal Error and halt the further process.
Include_once function include and execute specified file while in execution of the script. the main purpose of include_once is that once file included into the file then we can not include again in same file.

Q6. What is the difference between $ and $$ ?
Answer.
In this question $var is a simple PHP variable where $$var is a variables of variable.
Suppose $var has value $var = "Nishant"; and $$var = "is a good boy";
if we echo $var then it will echo the value "Nishant" and if we echo  $$var then it will echo Again "Nishant".

we can also write it as with best example: - echo "$var ${$var}";  // print Nishant is a good boy
                                             echo "$var $Nishant"; // print Nishant is a good boy

Q7. How to encrypt the Username and password in the PHP?
Answer: 

There are many function in php and phpmysql those performs the encryption and decryption, compression decompression.
ENCODE()        DECODE()

Base64 encode()      Base64 decode()      

DES_ENCRYPT()   DES_DECRYPT()

ENCRYPT()            Decryption is not available

MD5()                     Decryption not available

OLD_PASSWORD()  Not available

Not available            UNCOMPRESSED_LENGTH()

Q8. What is the difference between GET, POST and REQUEST methods.
Answer: 

There are some important factor for using it into the different projects.
Get Method has some limitation to send data up-to 2 KB on request. Shows all values into the browser URL.
Post Method has no limitation for sending data on request. do not show values into URL. so post method is generally used into the programming then GET method. its used for sending sensitive data from one page to another page.
Request Method is used to retrieve or catch get and post value from the browser URL.

Q9. What is cookies?
Answer:

Cookies are the flat files those store the user information.....

Q10. What is session and explain different type of session variable?
Answer:

When any user login into application then its all details is stored into the session variable so that details may be used on all pages for maintaining his or her availability.
There are different type of session variable in PHP.
session_start( ) = With this function we start the session for PHP application.

Storing the session variable.
$_session['value'] = 1;
in this, 1 is assign to session variable name value.

Destroying the session
Session_destory();
All session on application will be destroyed.


You Might Also Read : -

0 comments :

Post a Comment

 
# Top