2
Q:

PHP allows you to send emails directly from a script.

php allows you to send emails directly from a script

 

A) TRUE B) FALSE

Answer:   A) TRUE



Explanation:

The mail() function allows you to send emails directly from a script.

 

Q:

What is the difference between the functions unlink and unset in PHP?

Answer

The function unlink() is to remove a file, where as unset() is used for destroying a variable that was declared earlier.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

1 3461
Q:

What’s the difference between htmlentities() and htmlspecialchars()?

Answer

Htmlentities() converts all applicable characters to HTML entities. While htmlspecialcharacter()converts special characters to HTML entities. This means htmlentities( ) will check for non English language characters, such as French accents, the German umlaut, etc.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

3 1855
Q:

What is the difference between using copy() and move() function in php file uploading?

Answer

Copy() makes a copy of the file. It returns TRUE on success. It can copy from any source to destination. Move simply Moves the file to destination if the file is valid. While move can move the uploaded file from temp server location to any destination on the server. If filename is a valid upload file, but cannot be moved for some reason, no action will occur.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 2131
Q:

Explain the working with directories using opendir(), readdirs(), closedir() along with examples.

Answer

Opendir():- It opens the directory. This function returns a directory stream on success and FALSE and an error on failure.


Syntax:


Opendir(directory, context)


Context is a set of options that can modify the behavior of a stream


Example: opens sample directory.


$dir = opendir("directory");


 


Readdir(): It returns an entry from a directory handle opened by opendir().


Syntax:


Readdir(dir_stream)


Example:


$file = readdir($dir);


 


closedir(): It closes a directory handle opened by opendir().


Syntax:


closedir(dir_stream)


Example:


$file = close($dir);

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 3922
Q:

Explain the changing file permission and ownership using PHP's chmod() function.

Answer

Chmod() is used for changing permissions on a file.


Syntax:


Chmod(file, mode)


Mode here specifies the permissions as follows:


The first number is always zero


The second number specifies permissions for the owner


The third number specifies permissions for the owner's user group


The fourth number specifies permissions for everybody else


Possible values (to set multiple permissions, add up the following numbers)


1 = execute permissions


2 = write permissions


4 = read permissions


Example:


// everything for owner, read for owner's group


chmod("test.txt",0740);

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1696
Q:

How can we encrypt the username and password using PHP?

Answer

User names and passwords in PHP can be encrypted using md5 function.


MD5 function calculates the md5 hash of a string. It is basically used for encryption. It is also used for digital signature applications, where a large file must be "compressed" in a secure manner.


Example:


Md5($str);


 


Crypt() function can also be used to encrypt a string,. It used MD5, DES or blow fish algorithms for encryption.


Syntax:


Crypt(str, salt)


Salt is an optional parameter used to increase the number of characters encoded, to make the encoding more secure

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1947
Q:

What Is a Session in PHP?

Answer

A PHP Session persist the user information to be used later. For example, user name, password, shopping item details. The session is temporary and will be removed soon after the user has left the web site. The session can be persisted for long term usage on databases like MySQL. Each session is identified by a unique Id number for every visitor. The first step to use PHP session is to start the session. The starting session must precede the operations like HTML or the other.


The statement session_start() starts the PHP session and registers the user’s information on the server.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 2200
Q:

How to set cookies in PHP?

Answer

The function setcookie() is used to define a cookie that is to be sent along with HTTP headers. The cookie must be sent prior to any output from the script as is the protocol restriction. After setting the cookies, they can be used when the next page is loaded by using $_COOKIE or $HTTP_COOKIE_VARS arrays.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1748