Home |
Write |
147 members |
USA


Join with Aptibook
http://www.aptibook.com

PHP interview questions and answers - Page 1

1. What is PHP?

• PHP is a recursive acronym for "PHP: Hypertext Preprocessor".
• PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.

• It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.
• PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL server, once started, executes even very complex queries with huge result sets in record-setting time.

• PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.
• PHP Syntax is C-Like.


2. What are the common uses of PHP?

• PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
• PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.
• You add, delete, modify elements within your database through PHP.
• Access cookies variables and set cookies.
• Using PHP, you can restrict users to access some pages of your website.
• It can encrypt data.


3. What is the basic syntax of Php?

The PHP parsing engine needs a way to differentiate PHP code from other elements in the page.
Syntax: <?php...?>
A PHP scripting block can be placed anywhere in the document.


4. How can you run a PHP Script from Command Prompt?

You can run your PHP script on your command prompt.
Assuming you have following content in test.php file
<?php
echo "Hello PHP!!!!!";
?>

Now run this script as command prompt as follows:
$ php test.php

It will produce following result:
Hello PHP!!!!!


5. Variables in PHP (Things to remember)?

• All variables in PHP are denoted with a leading dollar sign ($).
• The value of a variable is the value of its most recent assignment.
• Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.

• Variables can, but do not need, to be declared before assignment.
• Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters.

• Variables used before they are assigned have default values.
• PHP does a good job of automatically converting types from one to another when necessary.
• PHP variables are Perl-like.