PHP Developer Interview Preparation Guide
Download PDF
Add New Question

PHP Developer Frequently Asked Questions by expert members with experience in PHP Developer. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts

57 PHP Developer Questions and Answers:

1 :: How I can download and Install PHP on Windows?

PHP is one of the most popular languages to develop dynamic Web pages. It supports all major database servers, including: MySQL, MS SQL Server, Oracle, mSQL, Sybase, etc.

If you are developing a Web application that uses PHP and needs to access MS SQL Server, you should go download and install PHP to your local machine to practice PHP and SQL Server connection. The best way to download and install PHP on Windows systems is to:

* Go to http://www.php.net, which is the official Web site for PHP.
* Click the Downloads menu link. You will see the PHP download page.
* Go to the "Windows Binaries" section, and click "PHP 5.2.3 zip package" link to download PHP binary version for Windows in ZIP format.
* Save the downloaded file, php-5.2.3-Win32.zip with 9,847,499 bytes, in C:Temp directory.
* Unzip the downloaded file into directory C:php.
You are done. No need to run any installation program.
Post Your Answer

2 :: How to check PHP Installation?

PHP provides two execution interfaces: Command Line Interface (CLI) and Common Gateway Interface (CGI). If PHP is installed in the php directory on your system, you can try this to check your installation:

* Run "phpphp -v" command to check the Command Line Interface (CLI).
* Run "phpphp-cgi -v" command to check the Common Gateway Interface (CGI).

If you see PHP printing the version information on your screen for both commands, your installation is ok. Open a command window and run the commands below:

C:>phpphp -v
PHP 5.2.2 (cli) (built: May 2 2007 19:18:26)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0 Copyright (c) 1998-2007 Zend Technologies

C:>phpphp-cgi -v
PHP 5.2.2 (cgi-fcgi) (built: May 2 2007 19:18:25)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0 Copyright (c) 1998-2007 Zend Technologies
Post Your Answer

3 :: How I can download and Install PHP for Windows?

The best way to download and install PHP on Windows systems is to:

► Go to http://www.php.net, which is the official Web site for PHP.
► Download PHP binary version for Windows in ZIP format.
► Unzip the downloaded file into a directory.
You are done. No need to run any install program.
Post Your Answer

4 :: How you can Run a PHP Script?

A standard alone PHP script can be executed directly with the PHP Command Line Interface (CLI). Write the following script in a file called hello.php:

<?php echo "Hello world!"; ?>
This script can be executed by CLI interface like this:
phpphp hello.php
You should see the "Hello world!" message printed on your screen.
Post Your Answer

5 :: Which special characters need to escape in Single-Quoted Stings?

There are two special characters you need to escape in a single-quote string: the single quote (') and the back slash (). Here is a PHP script example of single-quoted strings:

<?php
echo 'Hello world!';
echo 'It's Friday!';
echo ' represents an operator.';
?>
This script will print:
Hello world!It's Friday! represents an operator.

Answer #2
echo 'hi how are you';
echo ' it\'s free of cost';
echo 'end of the program';
?>
This script will print
Post Your Answer

6 :: How to specify the "new line" character in Single-Quoted Strings?

You can not specify the "new line" character in a single-quoted string. If you don't believe, try this script:
<?php
echo ' will not work in single quoted strings.';
?>

This script will print:
will not work in single quoted strings.
How Many Escape Sequences Are Recognized in Single-Quoted Strings?

There are 2 escape sequences you can use in single-quoted strings:
► - Represents the back slash character.
► ' - Represents the single quote character.
Post Your Answer

7 :: Which special characters need to escape in Double-Quoted Stings?

There are two special characters you need to escape in a double-quote string: the double quote (") and the back slash (). Here is a PHP script example of double-quoted strings:

<?php
echo "Hello world!";
echo "Tom said: "Who's there?"";
echo " represents an operator.";
?>
This script will print:
Hello world!Tom said: "Who's there?" represents an operator.
Post Your Answer

8 :: Tell me how many escape sequences are recognized in Double-Quoted Strings in PHP?

There are 12 escape sequences you can use in double-quoted strings:
► - Represents the back slash character.
► " - Represents the double quote character.
► $ - Represents the dollar sign.
► - Represents the new line character (ASCII code 10).
► - Represents the carriage return character (ASCII code 13).
► - Represents the tab character (ASCII code 9).
► { - Represents the open brace character.
► } - Represents the close brace character.
► [ - Represents the open bracket character.
► ] - Represents the close bracket character.
► nn - Represents a character as an octal value.
► xnn - Represents a character as a hex value.
Post Your Answer

9 :: How you can include variables in Double-Quoted Strings in PHP?

Variables included in double-quoted strings will be interpolated. Their values will be concatenated into the enclosing strings. For example, two statements in the following PHP script will print out the same string:
<?php
$variable = "and";
echo "part 1 $variable part 2 ";
echo "part 1 ".$variable." part 2 ";
?>

This script will print:
part 1 and part 2
part 1 and part 2
Post Your Answer

10 :: How many ways to include the variables in Double-Quoted Strings in PHP?

There are 3 formats to include variables in double-quoted strings:

► "part 1 $variable part 2" - This is the simplest format to include a variable in a string. The variable name starts with the dollar sign and ends at the first character that can not be used in variable name. Space is good character to end a variable name.
► "part 1${variable}part 2" - This format helps you to clearly end the variable name. The variable name starts at dollar sign before the open brace (${) and ends at the close brace (}).
► "part 1{$variable}part 2" - This format is also called complex format. You use this format to specify any complex variable expression in the same way as in a normal statement. The variable expression starts at ({$) followed by a variable name and ends at (}).

Here is a PHP script example of different ways to include variables in double-quoted strings:
<?php
$beer = 'Heineken';
echo "$beer's taste is great. ";
echo "He drank some ${beer}s and water. ";
echo "She drank some {$beer}s and water. ";
?>

This script will print:
Heineken's taste is great.
He drank some Heinekens and water.
She drank some Heinekens and water.
Post Your Answer
Add New Question