checkedresponsive[@]gmail.com

Menu

Essential PHP Interview Questions & Answer

1) Whats is CURL ?

A command line tools for sending and getting files and response.

2) How to use CURL in PHP ?

// Step 1
$cSession = curl_init();

// Step 2
curl_setopt($cSession,CURLOPT_URL,”http://www.yahoo.com/search?q=curl”);
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false);

//Step 3
$result=curl_exec($cSession);

//Step4
curl_close($cSession);

//Step5
echo $result;

3) How to access authenticated WEBSITE Datas in CURL ?

// http header:
“Authorization: Basic “. base64_encode(“username:password”);
// Set the below option for CURL
curl_setopt($ch, CURLOPT_USERPWD, ‘username:password’);

4) What is Buffer ?

Store all output results into a buffer for improving network performance.
Access the buffer data without sending request to browser

5) PHP Filters ?

$urlName = “https://www.checkedresponsive.com”;

if (!filter_var($urlName , FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED) === false) {
echo(“$urlName is a valid URL”);
} else {
echo(“$urlName is not a valid URL”);
}

FILTER_VALIDATE_INT – Validate numbers

FILTER_VALIDATE_IP – Validate IP Address

FILTER_VALIDATE_URL – Validate URL.

FILTER_VALIDATE_REGEXP – Validate Regular expression

FILTER_SANITIZE_EMAIL – Remove illegal character from the email id.

6) What is Array ?

An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string.

7) Sorting Array in PHP ?

sort() – Ascending order
rsort() – Descending order
asort() – Ascending order based on Value
ksort() – Ascending order based on Key
arsort() – Descending order based on Value
krsort() – Descending order based on Key

Leave a Reply

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