Thursday, August 20, 2015

PHP Interview Questions and Answers for Experienced basic advanced 2015-2016

PHP Interview Questions and Answers for Experienced basic advanced 2015-2016,PHP Interview Questions and Answers 2015,Top 20 PHP Interview Questions,PHP Interview Questions & Answers,PHP Interview Questions and Answers For Freshers and Experienced, PHP Frequently Asked Interview Questions,Freshers Latest PHP Technical Interview Questions & Answers,F2F Interview,PHP, Interview Questions & Answers,What would be some common PHP interview questions,PHP interview questions and answers for 2 years,PHP Developer Interview Questions,10 Common face to face PHP interview questions and answers,PHP Interview Questions and Answers,Top 10 PHP Interview Questions and Answers 2015,PHP (CMS)Interview Question Answer,Technical PHP Interview Questions and Answers for getting Job,Where can I find good PHP interview questions,PHP job interview questions and answers for freshers,PHP interview questions and answers for experienced,10 Tough PHP Interview Questions With Smart Answers,PHP interview questions and answers for experienced,How to Answer PHP Interview Questions,Where can I find good PHP interview questions ,Download PHP Interview Questions.

Question: What type of inheritance supports by PHP?

There are following type of inheritance
Single Inheritance - Support by PHP
Multiple Inheritance - Not support
Hierarchical Inheritance - Support by PHP
Multilevel Inheritance - Support by PHP


Question: How do you call a constructor for a parent class?

parent::constructor($value);


Question: What is the use of header() function in php?

1. Header is used to redirect from current page to another:
header("Location: newpage.php");

2. Header is used to send HTTP status code.
header("HTTP/1.0 404 Not Found");

3. Header is used to send Send a raw HTTP header
header('Content-Type: application/pdf');


Question: What are default session time and path?

Session Time: 1440 seconds
Session Path: /tmp folder in server


Question: What is the difference between the functions unlink and unset?

unlink: It is used to remove the file from server.
unlink('/path/file.phtml');

unset: It is used to remove the variable.
unset($variableName);

Question: What is MIME?

The Full form of MIME is "Multi-purpose Internet Mail Extensions".

It is extension of e-mail protocol helps to exchanges the different kids of data files over the internet.
Data files may be audio, video, images, application programs and ASCII etc.


Question: What do you mean by PEAR?

PHP Extension and Application Repository (PEAR) is a framework and repository for reusable PHP components.

Question: How to upload the file using CURL?

You can upload a file using CURL.

See following points.
1. Uploading file size must be less than allowed file by Server.
2. If file size is heady, May take more time.
3. replace "uploadFile.zip" with file which you want to upload WITH full path.
4. replace "http://localhost/test/index2" with URL where server has given functionality to upload file.

$file_name_with_full_path = realpath('uploadFile.zip');      
       $url = "http://localhost/test/index2";
       $post_data = array(
           "foo" => "bar",
           "upload" => "@".$file_name_with_full_path
       );
       try {
           $ch = curl_init();
           curl_setopt($ch, CURLOPT_URL, $url);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($ch, CURLOPT_POST, 1);
           curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
           $output = curl_exec($ch);
           curl_close($ch);
       } catch (Exception $e) {
           echo $e->getMessage();
           die;
       }


Question: How can we get the current session id?
echo session_id();

You can also set the session_id using same above function.


Question: Can I set the header in CURL?

Yes, you can set the header in CURL using CURLOPT_HEADER.
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));



Question: How can i execute PHP File using Command Line?

For this, you need PHP CLI(Commnd line interface)
Just login to you command line interface.
You have to prepend the "PHP" and need to mention the full-path/relative of file
Execute the file in following way.
php E://wamp/www/project/myfile.php


Question: What are different type of sorting functions in PHP?

sort() - sort arrays in ascending order. asort() - sort associative arrays in ascending order, according to the value.
ksort() - sort associative arrays in ascending order, according to the key.
krsort() - sort associative arrays in descending order, according to the key.
array_multisort() - sort the multi dimension array.
usort()- Sort the array using user defined function.
arsort() - sort associative arrays in descending order, according to the value.
rsort() - sort arrays in descending order.


Question: How to save the session data into database?

To maintain the session data, we can use session_set_save_handler function.
session_set_save_handler ( 'openFunction' , 'closeFunction', 'readFunction' , 'writeFunction' , 'destroyFunction', 'gcFunction' )

In this function, we provide 6 callback functions which call automatically.

For Example

openFunction will be called automatically when session start.
writeFunction will be called automatically when you write in the session.
destroyFunction will be called automatically when you destroy in the session.
gcFunction will be called automatically when session inactive for long time.
closeFunction will be called automatically when session end.
readFunction will be called automatically when you read the session.

0 comments:

Post a Comment