# PHP Questions

Q:

How to use HTTP Headers inside PHP? Write the statement through which it can be added?

HTTP headers can be used in PHP by redirection which is written as:

The headers can be added to HTTP response in PHP using the header(). The response headers are sent before any actual response being sent. The HTTP headers have to be sent before taking the output of any data. The statement above gets included at the top of the script.

Subject: PHP - Technology

16634
Q:

Why was PHP developed, what it is used for, and where can you get it?

PHP developed for less script, time saving, Free Open Source Software and runs on different platforms such as Windows, Linux, Unix, etc. PHP compatible with almost all servers used today such as Apache, IIS, etc.

The PHP scripting language resembles JavaScript, Java, and Perl, These languages all share a common ancestor, the C programming language. PHP has full access to the information that the server has, and very little access to information that the client has. In fact, it only has information that the client tells the server and that the server passes on to PHP. Because it is on the server, however, PHP cannot be modified by the client. While you cannot necessarily trust the information that the client gives to PHP, you can trust that your PHP is doing what you told it to do. Because PHP is on the server end, your PHP scripts can affect your server -- such as by keeping an activity log or updating a database.

Subject: PHP - Technology

8596
Q:

What type of inheritance that PHP supports? Provide an example.

PHP supports single level inheritance.

Inheriting a class would mean creating a new class with all functionality of the existing class in addition to some more. The created class is called as a subclass of the parent class. Parent is a keyword which we use to access members of a parent class. Inheritance is usually defined by using the keyword “Extend”. $this is used a reference to the calling object. Inheritance avoids redundancy of code. Example: Class employee extends manager : Here Employee is a subclass of manager. Echo$this->name can be used to echo variable name of the parent class.

Subject: PHP - Technology

8289
Q:

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

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

Subject: PHP - Technology

5363
Q:

What is PHP's configuration file called?

PHP’s configuration file is called php.ini.

Subject: PHP - Technology

5008
Q:

I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?

Answer PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.

Subject: PHP - Technology

4992
Q:

What is the difference between $argv and$argc? Give example?

To pass the information into the script from outside, help can be taken from the PHP CLI (Command line interface) method. Suppose addition of two numbers has to be passed to PHP then it can be passed like this on the command line:

Here the script name is add.php, and 2 and 3 are the numbers that has to be added by the script. These numbers are available inside the script in an array called $argv. This array contains all the information on the command line; the statement is stored as follows:$argv[0]=add.php

$argv[1]=2$argv[2]=3

So, $argv always contains at least one element — the script name. Then, in your script, you can use the following statements:$sum = $argv[1] +$argv[2];

echo $sum;$argc is a variable that stores the numbers of elements in $argv.$argc is equal to at least 1, which is saved for the name of the script. Example is \$argc=3 using the above statements.

Subject: PHP - Technology

4448
Q:

How can we display the output directly to the browser?