0% found this document useful (0 votes)
48 views3 pages

Echo vs. Print Statement.: Differences Between GET and POST Methods ?

The document discusses the differences between echo and print statements in PHP. Echo can take multiple expressions while print cannot. Print returns a boolean value indicating success or failure, while echo does not return any value. It also describes what sessions are in PHP - they allow storing user details using a unique ID for each visitor, making the information available across pages of an application.

Uploaded by

Anju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

Echo vs. Print Statement.: Differences Between GET and POST Methods ?

The document discusses the differences between echo and print statements in PHP. Echo can take multiple expressions while print cannot. Print returns a boolean value indicating success or failure, while echo does not return any value. It also describes what sessions are in PHP - they allow storing user details using a unique ID for each visitor, making the information available across pages of an application.

Uploaded by

Anju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Echo vs. print statement.

echo() and print() are language constructs in PHP, both are used to output strings. The
speed of both statements is almost the same.

echo() can take multiple expressions whereas print cannot take multiple expressions.

Print return true or false based on success or failure whereas echo doesn't return true or
false.

Describe session in PHP.


When a user logs in an application, his details are usually stored in a session variable. This
information is available to all pages in one application. Sessions in PHP work using a
unique id for each visitor.

Differences between GET and POST methods ?

1. What is the difference between Session and Cookie?

The main difference between sessions and cookies is that


sessions are stored on the server, and cookies are stored on
the users computers in the text file format. Cookies can not
hold multiple variables,But Session can hold multiple
variables.We can set expiry for a cookie,The session only
remains active as long as the browser is open.Users do not
have access to the data you stored in Session,Since it is stored
in the server.Session is mainly used for login/logout purpose
while cookies using for user activity tracking

2. How to set cookies in PHP?

Setcookie("sample", "ram", time()+3600);

3. How to Retrieve a Cookie Value?

eg : echo $_COOKIE["user"];
4. How to create a session? How to set a value in session ?
How to Remove data from a session?

Create session : session_start();


Set value into session : $_SESSION['USER_ID']=1;
Remove data from a session : unset($_SESSION['USER_ID'];

How to find the length of a string?

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

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 mean by an associative array?

Associative arrays are arrays that use string keys is


called associative arrays.

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

1. 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.
2. 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.

3. 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 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.

1. What is x+ mode in fopen() used for?

Read/Write. Creates a new file. Returns FALSE and an error if


file already exists

2. How to find the position of the first occurrence of a


substring in a string

strpos() is used to find the position of the first occurrence of


a substring in a stri

find output

You might also like