NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

IGNOU Best Coaching Institute NiPS Provides PHP Q/A

PHP QUESTION ANSWER BY IGNOU BEST COACHING INSTITUTE IN DELHI NIPS INSTITUTE 


For IGNOUFriend & IGNOU BCA MCA Students


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 );

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.

 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.

How to redirect a page in php?
The following code can be used for it, header("Location:index.php");

How stop the execution of a php scrip ?
exit() function is used to stop the execution of a page

   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

How to find the length of a string?
strlen() function used to find the length of a string

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.

what is the use of isset() in php?
This function is used to determine if a variable is set and is not NULL

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

What is mean by an associative array?
Associative arrays are arrays that use string keys is called associative arrays.

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.

What is the importance of "action" attribute in a html form?
The action attribute determines where to send the form-data in the form submission.

What is the use of "enctype" attribute in a html form?
The enctype attribute determines how the form-data should be encoded when submitting it to the server. We need to set enctype as "multipart/form-data"when we are using a form for uploading files

How to create an array of a group of items inside an HTML form ?
We can create input fields with same name for "name" attribute with squire bracket at the end of the name of the name attribute, It passes data as an array to PHP.
For instance :
<input name="MyArray[]" />  <input name="MyArray[]" />  <input name="MyArray[]" />  <input name="MyArray[]" />

Define Object-Oriented Methodology
Object orientation is a software/Web development methodology that is based on the modeling a real world system.An object is the core concept involved in the object orientation. An object is the copy of the real world enity.An object oriented model is a collection of objects and its inter-relationships

How do you define a constant?
Using define() directive, like define ("MYCONSTANT",150)

How send email using php?
To send email using PHP, you use the mail() function.This mail() function accepts 5 parameters as follows (the last 2 are optional). You need webserver, you can't send email from localhost. eg : mail($to,$subject,$message,$headers);

 How to find current date and time?
The date() function provides you with a means of retrieving the current date and time, applying the format integer parameters indicated in your script to the timestamp provided or the current local time if no timestamp is given. In simplified terms, passing a time parameter is optional - if you don't, the current timestamp will be used.

Difference between mysql_connect and mysql_pconnect?
There is a good page in the php manual on the subject, in short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends. mysql_connect()provides only for the databasenewconnection while using mysql_pconnect , the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection... the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use.

What is the use of "ksort" in php?
It is used for sort an array by key order.

What is the difference between $var and $$var?
They are both variables. But $var is a variable with a fixed name. $$var is a variable who's name is stored in $var. For example, if $var contains "message", $$var is the same as $message.

What are the encryption techniques in PHP
MD5 PHP implements the MD5 hash algorithm using the md5 function,
eg : $encrypted_text = md5 ($msg);
mcrypt_encrypt :- string mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] );
Encrypts plaintext with given parameters

What is the use of the function htmlentities?
htmlentities Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

 How to delete a file from the system
Unlink() deletes the given file from the file system.

How to get the value of current session id?

session_id() function returns the session id for the current session.

No comments:

Post a Comment