PHP Questions

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 - Technology

0 1827
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 - Technology

0 1824
Q:

What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

Answer

mysql_fetch_array:
Fetch a result row as an associative array and a numeric array.

mysql_fetch_object:
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows.

mysql_fetch_row():
Fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1819
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 1815
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 1814
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 - Technology

0 1808
Q:

How many types of Inheritances used in php and how we achieve it?

Answer

As far PHP concern it only support single Inheritance in scripting. we can also use interface to achieve multiple inheritance.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1798
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 - Technology

0 1788