Breaking News
Loading...
Monday 30 July 2012

PHP Interview Question and Answers

04:38
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
?>

42. Explain Creating and Naming an Array.

FunctionDescriptions
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

43. How to read and display a HTML source from the website url?

$filename="http://www.kaptivate.in/";
$fh=fopen("$filename", "r");
while( !feof($fh) ){
$contents=htmlspecialchars(fgets($fh, 1024));
print "
$contents
";
}
fclose($fh);
?>

44. How to display your correct URL of the current web page?

echo $_SERVER['PHP_SELF'];
?>

45. Explain $_FILES Superglobal Array.

ArrayDescriptions
$_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.

46. Explain mysql_error().

The mysql_error() message will tell us what was wrong with our query, similar to the message we would receive at the MySQL console.
47. What types of MYSQL function available in PHP?

Database FunctionDescriptions
1.mysql_connect()Opens a connection to a MySQL server.
2.mysql_pconnect()Opens a persistent connection.
3.mysql_selectdb()Selects the default database.
4.mysql_change_user()Changes the identity of the user logged on.
5.mysql_list_dbsLists databases for this MySQL server.
6.mysql_list_tablesLists tables in the database.

48. How to get no. of rows using MYSQL function?

Database FunctionDescriptions
1.mysql_fetch_assoc()Returns one result row, as an associative array.
2.mysql_fetch_row()Returns one result row, as an array.
3.mysql_affected_rows()Returns number of rows affected by query.
4.mysql_num_rows()Returns number of rows selected.
5.mysql_list_dbsLists databases for this MySQL server.
6.mysql_fetch_object()Returns a result row, as an object.


49. Explain mysql_errno().

Returns the numerical value of the error message from previous MySQL operation.

50. What types of MYSQL function available for affecting columns

ArrayDescriptions
mysql_fetch_field()Gets column information from a result and returns as an object.
mysql_field_name()Gets the name of the specified field in a result.
mysql_list_fields()Sets result pointer to a specified field offset.
mysql_num_fields()Gets number of fields in a result.
mysql_field_seek()Sets result pointer to a specified field offset.
mysql_field_type()Gets the type of the specified field in a result.
mysql_field_len()Returns the length of the specified field.
mysql_field_table()Gets name of the table the specified field is in.
mysql_tablename()Gets table name of field.


<< Next 1 2 3 4 5 Previous>>

Share This :
Tags:

0 comments:

Post a Comment

 
Toggle Footer