PHP Questions

Q:

What are the differences between GET and POST methods in form submitting?

Answer

On the server side, the main difference between GET and POST is where the submitted is stored. The $_GET array stores data submitted by the GET method. The $_POST array stores data submitted by the POST method.

On the browser side, the difference is that data submitted by the GET method will be displayed in the browser’s address field. Data submitted by the POST method will not be displayed anywhere on the browser.

GET method is mostly used for submitting a small amount and less sensitive data.
POST method is mostly used for submitting a large amount or sensitive data.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2091
Q:

Echo vs print statement

Answer

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.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2072
Q:

Why we use array_flip

Answer

array_flip exchange the keys with their associated values in array ie. Keys becomes values and values becomes keys.

<?php
$arrayName    = array("course1"=>"php","course2"=>"html");
$new_array    = array_flip($arrayName);
print_r($new_array);
?>

OUTPUT :

Array
(
[php]     => course1
[html]    => course2
)

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2041
Q:

How do you define a constant?

Answer Via define() directive, like define ("MYCONSTANT", 100);
Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2030
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

0 2007
Q:

What are the different types of errors in php?

Answer

Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour.

Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.

Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behaviour is to display them to the user when they take place.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 1994
Q:

Why many companies are switching their current business language to PHP? Where PHP basically used?

Answer

PHP is rapidly gaining the popularity and many companies are switching their current language for this language. PHP is a server side scripting language. PHP executes the instructions on the server itself. Server is a computer where the web site is located. PHP is used to create dynamic pages and provides faster execution of the instructions.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 1960
Q:

What is the functionality of md5 function in PHP?

Answer

Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number. I use it to generate keys which I use to identify users etc. If I add random no techniques to it the md5 generated now will be totally different for the same string I am using.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 1950