Saturday, October 14, 2017

anil

Best Interview Questions And Answers For Experienced PHP Developer


Question #1: How to get the location of php.ini?

You can get the location of php.ini by using <?php phpinfo(); ?> code.

Question #2: How to POST Data using CURL in PHP?

you can execute POST data by using CURL as below :


$data = array('name' => 'Ross', 'php_master' => true);
$url = 'http://domain.com/abc.php';
// You can POST a file by prefixing with an @ (for <input type="file"> fields)

$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
curl_exec($handle);
curl_close($handle);

Question #3: How to get duplicate values from array?

you can get duplicate values from an array by using array_diff_assoc($arr, $arr_unique); for an example :


<php 
         $arr = ('anil','anil','sonia','monica','sunita','sunita','raj');
         $arr_unique = array_unique($arr);
         $arr_duplicates = array_diff_assoc($arr, $arr_unique);
         print_r($arr_duplicates);
?>

It will return :
Array(
                          [1] => anil
                          [2] => sunita
)

Question #4: How to identify server IP address in PHP?

you can identify server IP address by using $_SERVER['SERVER_ADDR']; 

Question #5: What is the difference between explode() and split() functions?


Split function splits string into array by regular expression. Explode splits a string into array by string.
Both function are used to breaks a string into an array, the difference is that Split() function breaks split string into an array by regular expression and explode() splits a string into an array by string. explode() is faster than split() because it does not match the string based on regular expression.  
Question #6: What is difference between require_once(), require() and include() function ?

require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
Question #7: What is use of header() function in PHP ?

Header() function is mostly used to Redirect from one page to another -

<?php header("Location:page.php"); ?>

Question #8: What type of inheritance does not support by PHP ?

Only Multiple Inheritance does not support by PHP.

Question #9: What is PEAR?

PEAR stands for PHP Extension and Application Repository. PEAR is a framework and repository for re-usable PHP components.

Question #10: What are different types of errors in PHP ?

  1. E_WARNING: It is a run-time warning that does not cause script termination.
  2. E_ERROR: It is a fatal error that causes script termination.
  3. E_NOTICE: It is a run time notice caused due to error in code.
  4. E_CORE_WARNING: Warnings that occur during PHP's initial startup.
  5. E_PARSE: Compile time parse error.
  6. E_CORE_ERROR: It is a fatal errors that occur during PHP's initial startup
  7. E_COMPILE_ERROR: Fatal compile-time errors indication problem with script.
  8. E_USER_WARNING: It is a user-generated warning message.
  9. E_USER_NOTICE: User-generated notice message.
  10. E_USER_ERROR: User-generated error message.
  11. E_STRICT: Run-time notices.
  12. E_RECOVERABLE_ERROR: It is a catchable fatal error indicating a dangerous error 
  13. E_ALL: Catches all errors and warnings 

Question #11 - Write down the code for save an uploaded file in php.


if ($_FILES["file"]["error"] == 0) {
move_uploaded_file($_FILES["file"]["tmp_name"],       "upload/" . $_FILES["file"]["name"]);       echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; }

Question #12 - How to create a text file in php?


$filename = "/home/user/guest/newfile.txt"; $file = fopen( $filename, "w" ); if( $file == false ) { echo ( "Error in opening new file" ); exit(); } fwrite( $file, "This is a simple test\n" ); fclose( $file );


About Author -

Hi, I am Anil.

Welcome to my eponymous blog! I am passionate about web programming. Here you will find a huge information on web development, web design, PHP, Python, Digital Marketing and Latest technology.

Subscribe to this Blog via Email :

Note: Only a member of this blog may post a comment.