Basic PHP Programming Interview Preparation Guide
Download PDF
Add New Question

Learn PHP programming with Interview Questions and Answers and examples.

138 PHP Questions and Answers:

1 :: How To 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 Your 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 To 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 :: Where Are PHP Configuration Settings Stored?

PHP stores configuration settings in a file called php.ini in PHP home directory. You can open it with any text editor to your settings.
Post Your Answer

5 :: How To 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

6 :: What Are the Special Characters You 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.
Post Your Answer

7 :: Can You 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

8 :: What Are the Special Characters You 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

9 :: 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

10 :: How To 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
Add New Question