Professional Documents
Culture Documents
PHP Assignment
PHP Assignment
PHP Assignment
QUESTION BANK
1 ST UNIT
DONE BY :
20-ucs-029
20-ucs-032
20-ucs-033
20-ucs-042
20-ucs-044
20-ucs-046
2 Marks :
1.Benefits of PHP :
• PHP is a platform Independent general purpose Scripting language.
• Since it is platform Independent, it supports all as like windows, Unix,
Linux.
• PHP has built in modules which helps to connect to database easily.
2. Benefits of MySQL :
• MySQL is considered easy to use
• MySQL is a highly scalable product
• MySQL’s maturity also lends itself to security
3. Benefits of Javascript :
• Javascript is a open source programming language which means it has
a huge community support
• JavaScript allows third party integration
• The most significant benefit using this language is on the client-side
4. Benefits of CSS :
• CSS saves time in which we can write CSS once and then reuse the
same sheet in multiple HTML pages
• CSS is easy to maintain
• CSS changes are device friendly
A variable can have a short name (like x and y) or a more descriptive name.
Rules for PHP variables:A variable starts with the $ sign and it can start with a
letter or the underscore character.
An array is a special variable that we use to store or hold more than one
value in a single variable without having to create more variable to store those
values.
16.Type of arrays :
* Assossiative array
* Indexed array
* Linear array
Php supports many databases like MYSql and Postgre Sql etc.
Php file can contain text, HTML, CSS, JavaScript and php code.
Php parser is a library that takes a source code which in php, parses it
through a logical analyzer, and creates its respective syntax tree.
Php parser, Php Sundbox, Php Mess Detector, Php checkstyle, Php
analyzer.
Parsers are used when there is a need to represent input data from
source code abstractly as a data structure so that it can be checked for the
current syntax.
<?php
?>
Output :
Hello and Hi
The server executes the php scripts, which will send the html output to
the browser. Normally HTML and php tags can be present. A popular open
source general programming language, php or hypertext pre processor may be
built into an html.
• Good flexibility.
• Conditional Statement
• Loop statement
• Jump Statement
• if statement
• if else statement
• For loop
• while loop
• do while loop
• Go to
• Continue
<?php
$a=2;
$b=3;
if($a<$b)
{ echo “ a is smaller”; }
Else
{ echo “ b is smaller”; }
?>
Loops are used to execute the same block of code again and again as
long as a certain condition is true.
Code to be executed
}
38. Write static and dynamic linking.
Static linking :
Dynamic linking :
10 MARK :
Features :
* Speed
* Cross platform.
* Support for a wide range of database. Eg: dbase, Mysql, Oracle etc.
* Support for talking to other services using protocols such as IMAP, POP3,
HTTP.
* Php includes free and open source libraries with the case build.
Working :
* Url is typed in the browser.
* The web server then calls the Php script on that page.
* The php module executes the script, which then sends out the result in the
form of HTML back to the browser, which can be seen on the screen.
Php parser is a library that takes a source code which in php, parses it
through a logical analyzer, and creates its respective syntax tree.
It analyzes the whole document, and provides access to the Tree elements
(DOM).
This type of parser is a better option for smaller XML documents, but not for
large XML document as it causes major performance issues.
* Simple XML
* DOM
This type of parser is well suited for large XML documents. Its parsers faster
and consumes less memory.
* XML reader
<html>
<body>
<?php
echo"hi freinds....";
?>
</body>
</html>
A php script can be placed anywhere in the document. A php script starts
with <?php and
The default file extension for php files is ".php". A php file normally contains
HTML tags,
and some php scripting code. This means that php code is embedded in HTML
code.
5. Explain if and if else statements with example.
we can use conditional statements in our code to do this. In php we have the
following conditional statements.
i) if statement :
Syntax :
if(condition)
code to be executed
Example:
<?php
$a=10;
if($a==10)
echo"Correct";
?>
Output :
Correct
In this example the variable a is declared 10 and the if condition gets satisfied
so the statement
ii) if else :
When we need to display one code when the condition is true and
another code when the condition is false, then if else statement is used.
Syntax:
if(condition)
else {
Example :
<?php
$a=10;
if($a==5)
echo"Entered";
}
else {
echo"Error value";
?>
Output :
Error value
In the above example the condition is false (variable a is not 10), so the else
block is executed.
i) if elseif else:
When a selected code need to be executed among many codes then this
statement is used.
Syntax :
if(condition)
code to be executed
elseif(condition){
code to be executed
else{
code to be executed
Example :
<?php
$a=10;
if($a==100){
echo "Okay";
else if($a==10){
echo "perfect";
else{
echo "Error";
?>
Output :
perfect
In the above example the condition satisfies the elseif block, so the code in
the elseif
block executed.
ii) switch :
When a selected code used to be executed among many codes, then this
statement is used.
Syntax :
switch($n){
case 1:
case 2:
default:
Example :
<?php
$a=10;
switch($a)
case 3:
echo "3";
case 10:
echo "10";
default:
echo "Error";
?>
Output :
10
from continuing.
i) for:
Syntax :
code to be executed
The init is the initial value, condition is the one which needs to be executed,
and the increment value is used to set the values by which need to be
incremented.
Example :
<?php
for($a=1;$a<6;a++)
echo "$a";
}
?>
Output :
12345
ii) foreach :
This statement is used to access the elements in the array. The variable
should
assign to $ value.
Syntax :
foreach($a as $ value)
code to be executed
Example :
<?php
$a=array("car","bike");
foreach($a as $ value)
}
?>
Output :
car
bike
In the above example $a is assigned with array constitutes values car and
bike. Then $a
is assigned to $ value. Then the values are displayed using echo function.
i) while :
Syntax :
while(condition)
code to be executed;
increment value;
Example :
<?php
$a=1;
while($a<3)
{
echo "$a";
$a=$a+1;
Output :
12
ii) do while:
Here the code is executed once. Then the condition is checked and the
loop runs
Syntax :
do{
code to be executed;
increment value;
while(condition)
Example :
<?php
$a=10;
do{
echo "$a";
$a++;
while($a<5)
?>
Output :
10
In the above example value is 10. The value once displayed. Then the
condition
it’s much more sensible to split your website development into different parts.
For example, one distinct process is signing up for a website, along with all the
checking this entails to validate an email address, check whether a username is
already taken, and so on.
One of the more popular PHP-driven applications on the Web today is the
blogging platform WordPress or a blog reader, you might not realize it, but
every major section has been given its own main PHP file, and a whole raft of
generic, shared functions have been placed in separate files that are included
by the main PHP pages as necessary.
<?php
$PDO->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
// Set up defaults
$current_title = "";
$current_page_data = "";
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST["menu"])) {
// Now get current data from the database, if the page was never
created, add it to the database
$stmt->execute([$current_title]);
$row = $stmt->fetch();
if($row) {
} else {
?>
a)HTTP :
• Hyper Text is a multi-linear set of objects that are used to build a network by
using hyperlinks
Purpose of HTTP:
a web browser) and a web browser. Also it is the primary protocol for
transmission of
b)HTML :
• HTML is written using HTML elements which consists of tags, primarily and
opening and
closing tag
• It is a system which is used to mark text for World Wide Web page in order
to obtain
Purpose of HTML :
HTML is the code that is used to structure a web page and its content.
11. List out the benefits of PHP and MySql.
i) Benefits of PHP :
• Since PHP it has been for open source 21 years, Most bugs are discovered
and resolved by
• It can work efficiently with different databases, such as Apache, MySQL and
PostgreSQL.
• PHP can be integrated without effort with other technologies such as java
which saves time
and money.
• MySQL is reliable -not just from a data perspective, but from a development
perspective
with it
• This makes MySQL a safe choice compared to newer, less mature RDBMS
options
i) Benefits of JAVASCRIPT :
support
browser
• The essential benefit of Javascript is that you would be able to create highly
efficient
multifunctional websites
• CSS saves time in which we can write CSS once and then reuse the same
sheet in multiple
HTML pages
• Cascading Sheet not only simplifies website development, but also simplifies
the maintenance
• Apache is a free and open-source web server that delivers web content
through the internet
• Being open-source has made Apache very popular with developers who have
built and
• Apache has been around since 1995 and is responsible as a core technology
that helped the
• Apache has its ability to handle large amounts of traffic with minimal
configuration
• Apache can process dynamic contexts within the webserver itself without
having to rely on any
external components.
• The name 'Apache' was chosen from respect for the various Native American
nations
• The Apache HTTP server allows loading modules with extensive support for