1.What is PHP?
Ans:PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique.
PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.
2.What's PHP do?
Ans:Reduce the time to create large websites.
Create a customized user experience for visitors based on information that you have gathered from them.
Open up thousands of possibilities for online tools. Allow creation of shopping carts for e-commerce websites.
3.What does PHP stand for?
Ans:PHP stands for PHP: Hypertext Preprocessor. This confuses many people because the first word of the acronym is the acronym.This type of acronym is called a recursive acronym.
4.What is the difference between echo and print statement?
Ans:echo() can take multiple expressions,Print cannot take multiple expressions.
echo has the slight performance advantage because it doesn't have a return value.
True, echo is a little bit faster.
5. What are magic quotes in PHP?
Ans:Some special characters in PHP like, single quote( ' ), double quote( " ), amperson ( & ) etc. are escape by slash its called magic quotes. Its useful for beginner programmer.
6.How do get all the results from a select multiple HTML tag?
Ans:The select multiple tag in an HTML construct allows users to select multiple items from a list. These items are then passed to the action handler for the form. The problem is that they are all passed with the same widget name. I.e.
<select name="var" multiple="yes">
Each selected option will arrive at the action handler as:
var=option1
var=option2
var=option3
Each option will overwrite the contents of the previous $var variable. The solution is to use PHP's "array from form element" feature. The following should be used:
<select name="var[]" multiple="yes">
This tells PHP to treat $var as an array and each assignment of a value to var[] adds an item to the array. The first item becomes $var[0], the next $var[1], etc. The count() function can be used to determine how many options were selected, and the sort() function can be used to sort the option array if necessary.
Note that if using JavaScript the [] on the element name might cause problems when you try to refer to the element by name.
Use it's numerical form element ID instead, or enclose the variable name in single quotes and use that as the index to the
elements array, for example:
variable = documents.forms[0].elements['var[]'];
7.what is difference between $message and $$message?
Ans:$message in simple variable and $$message in refrence variable.
For example
$message="hello";
$$message=$message;
echo $$message;
//It will print hello on the screen
8.How to get the URL domain name in PHP?
Ans:By using: $_server[HTTP_HOST]
eg:
<? $domain=$_SERVER['HTTP_HOST'];
echo $domain;?>
will result the domain name.
9.What are the types of errors in PHP?
Ans:There are three types of errors:
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour.
2.Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default,these errors are displayed to the user, but they do not result in script termination.
3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP's default behaviour is to display them to the user when they take place.
10.What is Joomla?
Ans:Joomla! is one of the most powerful and an award-winning Open Source Content Management System (CMS) that will help you build everything from simple websites to complex corporate applications. Joomla! is easy to install, simple to manage, and reliable. Best of all, Joomla! is an open source solution that is freely available to everybody.
11.What is Joomala in PHP?
Ans:Joomla is a Content Management System. It is built in PHP language and easily modified the site with content.
12.PHP vs. ASP?
Ans:ASP is not really a language in itself, it's an acronym for Active Server Pages, the actual language used to program ASP with
is Visual Basic Script or JScript. The biggest drawback of ASP is that it's a proprietary system that is natively used only on Microsoft Internet Information Server (IIS). This limits it's availability to Win32 based servers. There are a couple of projects in the works that allows ASP to run in other environments and webservers: » InstantASP from » Halcyon (commercial),
Chili!Soft ASP from » Chili!Soft (commercial). ASP is said to be a slower and more cumbersome language than PHP, less stable as well. Some of the pros of ASP is that since it primarily uses VBScript it's relatively easy to pick up the language if you're already know how to program in Visual Basic. ASP support is also enabled by default in the IIS server making it easy to get up and running. The components built in ASP are really limited, so if you need to use "advanced" features like interacting with FTP servers, you need to buy additional components.
13.How can pass a variable from Javascript to PHP?
Ans:Since Javascript is (usually) a client-side technology, and PHP is (usually) a server-side technology, and since HTTP is a "stateless" protocol, the two languages cannot directly share variables. It is, however, possible to pass variables between the two. One way of accomplishing this is to generate Javascript code with PHP, and have the browser refresh itself, passing specific variables back to the PHP script. The example below shows precisely how to do this -- it allows PHP code to capture screen height and width, something that is normally only possible on the client side.
<?php
if (isset($_GET['width']) AND isset($_GET['height'])) {
// output the geometry variables
echo "Screen width is: ". $_GET['width'] ."<br />\n";
echo "Screen height is: ". $_GET['height'] ."<br />\n";
} else {
// pass the geometry variables
// (preserve the original query string
// -- post variables will need to handled differently)
echo "<script language='javascript'>\n";
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
. "&width=\" + screen.width + \"&height=\" + screen.height;\n";
echo "</script>\n";
exit();
}
?>
14.What is the difference between if-else-if and switch statement in PHP?
Ans:"switch" statements are faster because with a switch, PHP compares an original value to a set of case values, the same holds with javascript... With an if else statement, it needs to do more parsing.
15.What are magic quotes in PHP?
Ans:Some special characters in PHP like, single quote( ' ), double quote( " ), amperson ( & ) etc. are escape by slash its called magic quotes. Its useful for beginner programmer.