PHP Interview Question and Answers

41. What do you mean range()?
  Starting from a low value and going to a high value, the range() function creates an array of consecutive integer or character values. It takes up to three arguments: a starting value, an ending value, and an increment value. If only two arguments are given, the increment value defaults to 1.
Example :
<?php
echo range(1,10); // Returns 1,2,3,4,5,6,7,8,9,10
?>
 
Your Name Your Email-ID
Your Answer
42. Explain Creating and Naming an Array.
 
  Function Descriptions
1. array() Creates an array
2. array_combine() Creates an array by using one array for keys and another for its values
3. array_fill() Fills an array with values
4. array_pad() Pads an array to the specified length with a value
5. compact() Creates array containing variables and their values
6. range() Creates an array containing a range of elements
 
Your Name Your Email-ID
Your Answer
43. How to read and display a HTML source from the website url?
  <?php
$filename="http://www.kaptivate.in/";
$fh=fopen("$filename", "r");
while( !feof($fh) ){
$contents=htmlspecialchars(fgets($fh, 1024));
print "<pre>$contents</pre>";
}
fclose($fh);

?>
 
Your Name Your Email-ID
Your Answer
44. How to display your correct URL of the current web page?
  <?php
echo $_SERVER['PHP_SELF'];
?>
 
Your Name Your Email-ID
Your Answer
45. Explain $_FILES Superglobal Array.
 
Array Descriptions
$_FILES['userfile']['name'] The original name of the file on the client machine.
$_FILES['userfile']['type'] The MIME type of the file, if the browser provided this information. An example would be "image/gif".
$_FILES['userfile']['size'] The size, in bytes, of the uploaded file.
$_FILES['userfile']['tmp_name'] The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES['userfile']['error'] The error code associated with this file upload.
 
Your Name Your Email-ID
Your Answer
123456789101112


131415161718 Page 10 of 18