PHP Interview Questions For 2 Years Experienced Candidates

Dear Reader, here we are going to make you understood about “PHP Interview Questions For 2 Years Experienced Candidates” which we watch out that the Interviewer wants:-

1. the creativity of the person that they are very creative, not just in problem-solving but in general too

2. developers who are constantly learning new things

3. they are driven by curiosity

Interviewer mostly uses to ask combo pack of PHP and SQL. So prepare accordingly and we are sure that you will crack the door.

 

Question: What is the use of header() function in PHP?
1. A header is used to redirect from the current page to another:

header(“Location: newpage.php”);

2. A header is used to send HTTP status code.

header(“HTTP/1.0 404 Not Found”);

3. A header is used to send Send a raw HTTP header

(‘Content-Type: application/pdf’);

Question: What type of inheritance supports by PHP?
There are the 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 difference between the functions unlink and unset?
unlink: It is used to remove the file from a server.

unlink(‘/path/file.phtml’);

unset: It is used to remove the variable.

unset($variableName);

Question: What are default session time and path?
Session Time: 1440 seconds
Session Path: /tmp folder in server

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

Question: What is MIME?
Full form of MIME is “Multi-purpose Internet Mail Extensions”.
It is the 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: How to scrape the data from website using CURL?
To scrap the data from a website, Website must be public and open for scrapable.
In the blow code, Just update the CURLOPT_URL to which websites data you want to scrap.

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 the file size is heady, May take more time.
3. replace “uploadFile.zip” with the file which you want to upload WITH full path.
4. replace “http://localhost/test/index2” with URL where the server has given functionality to upload the file.

Question: Can I set the header in CURL?
Yes, you can set the header in CURL using CURLOPT_HEADER.

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: How can we get the current session id?

echo session_id();

You can also set the session_id using same above function.

Question: What are the 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.
arsort() – sort associative arrays in descending order, according to the value.
rsort() – sort arrays in descending order.
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.

Question: How to Swap two variables value without using the third variable? 

1st  Method :-

The Output will be :-
2nd Method :-
Hence the output will be :-
«
»

2 Comments:

  • paul george shoes April 25, 2018

    I have to get across my appreciation for your kindness supporting people who actually need help with in this idea. Your very own dedication to passing the solution around was definitely effective and have always allowed guys and women just like me to get to their goals. Your entire insightful advice implies a great deal to me and somewhat more to my fellow workers. Thanks a ton; from each one of us.

    Reply

    • Webpreparations Team April 25, 2018

      Thank you Dear Reader 🙂

      Reply

Leave a comment:

Your email address will not be published. Required fields are marked *