IGNOU BCA MCA Students - VIVA Question Answer for PHP
PHP Selected Question Answer - PART IV
1. 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 );
$file = fopen( $filename, "w" );
if( $file == false )
{
echo ( "Error in opening new file" ); exit();
}
fwrite( $file, "This is a simple test\n" );
fclose( $file );
2. How to strip whitespace (or other characters) from the beginning
and end of a string ?
The trim() function removes
whitespaces or other predefined characters from both sides of a string.
3. What is the use of header() function in php ?
The header() function sends
a raw HTTP header to a client browser.Remember that this function must be
called before sending the actual out put.For example, You do not print any HTML
element before using this function.
4. How to redirect a page in php?
The following code can be
used for
it, header("Location:index.php");
5. How stop the execution of a php scrip ?
exit() function is used to stop the execution of a page
6. How to set a page as a home page in a php based site ?
index.php is the default name of the home page in php based sites
7. How to find the length of a string?
strlen() function used to find the length of a string
8. what is the use of rand() in php?
It is used to generate random numbers.If called
without the arguments it returns a pseudo-random integer between 0 and
getrandmax(). If you want a random number between 6
and 12 (inclusive), for
example, use rand(6, 12).This function does not generate cryptographically safe values, and should not be used for
cryptographic uses. If you want a cryptographically secure value, consider
using openssl_random_pseudo_bytes() instead.
9. what is the use of isset() in php?
This function is used to
determine if a variable is set and is not NULL
10.
What is the difference
between mysql_fetch_array() and mysql_fetch_assoc() ?
mysql_fetch_assoc function Fetch a result row as an associative array, Whilemysql_fetch_array() fetches an associative array, a numeric array, or both
11.
What is mean by an
associative array?
Associative arrays are
arrays that use string keys is called associative arrays.
12.
What is the importance of
"method" attribute in a html form?
"method"
attribute determines how to send the form-data into the server.There are two
methods, get and post. The default method is get.This sends the form
information by appending it on the URL.Information sent from a form with the
POST method is invisible to others and has no limits on the amount of
information to send.
No comments:
Post a Comment