PHP Interview Questions

1) What is PHP?

PHP-(Hypertext Preprocessor) is a web language based on scripts that allows developers to dynamically create generated web pages.

2) What is the difference between $name and $$name?

$name is variable where as $$name is reference variable
like $name=Sadiq and $$name=Akhtar so $Sadiq value is Akhtar.

3) What’s the difference between md5(), crc32() and sha1() crypto on PHP?

The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit md5() returns a 160 bit value. This is important when avoiding collisions.

4) What is the difference between require_once(), require(), include_once() and include() in PHP?

require_once()
It includes a spcified file.
a file has already been included, it will not be included again.
It will produce a a fatal error if it fail to find the file and stops the ececution.
require()
It includes a spcified file.
It will produce a fatal error if it fail to find the file and stops the ececution.
include_once()
It includes a spcified file.
a file has already been included, it will not be included again.
It will produce a a warning if it fail to find yhe file and execute the remaining scripts.
include()
It includes a spcified file.
It will produce a a warning if it fail to find the file and execute the remaining scripts.

5) What does the unlink() function means?

The unlink() function is dedicated for file system handling. It simply deletes the file given as entry.
Example:
unlink('test.php');
It will delete the test.php file from the file system.

6) What is the difference between $_FILES['userfile']['name'] and $_FILES['userfile']['tmp_name']?

$_FILES['userfile']['name'] represents the original name of the file on the client machine,
$_FILES['userfile']['tmp_name'] represents the temporary filename of the file stored on the server.

7) What are the different types of errors in PHP? 

Different types of errors are :
    E_ERROR: A fatal error that causes script termination
    E_WARNING: Run-time warning that does not cause script termination
    E_PARSE: Compile time parse error.
    E_NOTICE: Run time notice caused due to error in code
    E_CORE_ERROR: Fatal errors that occur during PHP's initial startup (installation)
    E_CORE_WARNING: Warnings that occur during PHP's initial startup
    E_COMPILE_ERROR: Fatal compile-time errors indication problem with script.
    E_USER_ERROR: User-generated error message.
    E_USER_WARNING: User-generated warning message.
    E_USER_NOTICE: User-generated notice message.
    E_STRICT: Run-time notices.
    E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
    E_ALL: Catches all errors and warnings.

8) How to set cookies in PHP?

Cookies are often used to track user information.
Syntax :
Setcookie(name, value, expire, path, domain);
eg: Setcookie(“sample”, “ram”, time()+3600);

9) How to calculate the sum of values in an array ?

"array_sum" method used for calculate sum of values in an array.

10) What are the differences between Get and post methods ?

There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request.


1 comment:

  1. Is these questions taken our normal interview process for PHP developers for http://www.knowledgehut.com , please confirm so that we change our interview pattern a bit.

    ReplyDelete