You are on page 1of 39

SOFTPRO INDIA COMPUTER TECHNOLOGIS PVT.

SOFTPRO TOWER ALIGANJ LUCKNOW

A TRAINING REPORT

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD


OF THE DEGREE OF

BACHELOR OF TECHNOLOGY
(Computer Science & Engineering)

SUBMITTED TO
DR.A.P.J.ABDUL KALAM TECHNICAL UNIVERSITY, LUCKNOW

SUBMITTED BY

Name of Student:- University Roll


No.
Mayank Mishra
1642810031

10-06-2019 to 25-07-2019

KASHI INSTITUTE OF TECHNOLOGY,


VARANASI, UTTAR PRADESH
Kashi Institute of Technology, Varanasi

TRAINEE BIODATA

Student Name :Mayank Mishra

Roll No
: 1642810031

Computer
Branch Science And
: Technology

Period of Training
: 10/06/2019 To 25/07/2019

Name & Address of


Organization
: Softpro India,Aliganj,Lucknow

Office Incharge of
Training Mr. Rohit Kumar
:
ACKNOWLEDGEMENT

I would like to place on record my deep sense of gratitude to Mr. Rohit Kum
Supervisor / Manager for his generous guidance, help and useful suggestions.

I also wish to extend my thanks to Mr.Avanish and other workers for guiding and
providing the knowledge related to hardware & software’s.

I am extremely thankful to Dr. Ashish Chaurasia, Head, Department of Computer


Science & Engineering, KIT, Varanasi, for valuable suggestions and encouragement.

Signature of Student

Mayank mishra(1642810031)
About Company:-

 Softpro India was founded in 2004, by a group of Technocrats from IIT & IET. We are a
renowned name in the area of software development & training.

 It is a dynamic new generation software solution as well as Networking Product


Development company. The company develop, markets, sells and supports software
products, web-portals, Network Projects and offers turnkey solutions to the customers.

 Softpro India has two more wings apart from software development namely:
Softpro Learning Center (SLC): provides IT training to IT students & IT professionals.
Softpro Research Center (SRC): involved in research & development.

 Founding date
2004

 Products
 Application software, Web portals, Web based solutions, SEOs, Internships and many
more.... A new feature "Android based applications"
CERTIFICATE

I hereby certify that I have completed the Six week Training in partial fulfillment of the

requirements for the award of Bachelor of Technology in Computer Science & Engineering . I

did my training in PHP from 10-06-2019 to 25-07-2019.

The matter presented in this Report has not been submitted by me for the award of any

other degree elsewhere.

Signature of Student

Mayank Mishra
(1642810031),

Head,
CSE, VSGOI
CERTIFICATE
TABLE OF CONTENTS

Title Page No.


 ACKNOWLEDGEMENT 3

 ABOUT COMPANY 4

 INTRODUCTION 8-9

 HTML 10-15

 CSS 16-20

 JAVASCRIPT 21-24

 SQL 25-31

 PHP 32-36

 RESULTS AND DISCUSSION 37

 CONCLUSION 38

 REFERENCE 39
W
O
R
K
I
N
G

D
A
Y
S

A
N
D

W
O
R
K
Chapter 1
Introduction

The term PHP is an acronym for PHP: Hypertext Preprocessor. PHP is a server-side scripting language
designed specifically for web development.
1. Websites like www.facebook.com, www.yahoo.com are also built on PHP.
2. One of the main reason behind this is that PHP can be easily embedded in HTML files and
HTML codes can also be written in a PHP file.
3. The thing that differentiates PHP with client-side language like HTML is, PHP codes are
executed on server whereas HTML codes are directly rendered on the browser. PHP codes are
first executed on the server and then the result is returned to the browser.
4. The only information that the client or browser knows is the result returned after executing
the PHP script on the server and not the actual PHP codes present in the PHP file. Also, PHP
files can support other client-side scripting languages like CSS and JavaScript.
5. PHP is an acronym for "PHP Hypertext Pre-processor” PHP is a widely-used, open source
scripting language PHP scripts are executed on the server PHP costs nothing, it is free to
download and use

Why should we use PHP?

PHP can actually do anything related to server-side scripting or more popularly known as the
backend of a website. For example, PHP can receive data from forms, generate dynamic page content,
can work with databases, create sessions, send and receive cookies, send emails etc. There are also
many hash functions available in PHP to encrypt user’s data that makes PHP secure and reliable to be
used as a server-side scripting language. So these are some of the abilities of PHP that makes it
suitable to be used as server-side scripting language. You will get to know more of these abilities in
further tutorials.
1.1 HTML

HTML (Hyper Text Mark up Language) is a language for specifying how text and graphics appear on a
web page When you visit a web site (e.g., www.google.com)your web browser retrieves the HTML
web page and renders it The HTML page is actually stored on the computer that is hosting the web
site and the page is sent to your browser To see what HTML looks like go to your web browser View
menu and select View Source. HTML is written in the form of HTML elements consisting of tags
enclosed in angle brackets (like <html>), within the web page content. HTML tags most commonly
come in pairs like <h1> and </h1>, although some tags represent empty elements and so are
unpaired, for example <img>. The first tag in a pair is the start tag, and the second tag is the end tag
(they are also called opening tags and closing tags). In between these tags web designers can add
text, further tags, comments and other types of text-based content.

Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>


<p>My first paragraph.</p>

</body>
</html>

Example Explained
 The <!DOCTYPE html> declaration defines this document to be HTML5
 The <html> element is the root element of an HTML page
 The <head> element contains meta information about the document
 The <title> element specifies a title for the document
 The <body> element contains the visible page content
 The <h1> element defines a large heading
 The <p> element defines a paragraph
HTML Elements

An HTML element usually consists of a start tag and an end tag, with the content inserted in between:

<tagname>Content goes here...</tagname>

The HTML element is everything from the start tag to the end tag:

<p>My first paragraph.</p>

Start tag Element content End tag

<h1> My First Heading </h1>

<p> My first paragraph. </p>

<br>

HTML elements with no content are called empty elements. Empty elements do not have an end tag,
such as the <br> element (which indicates a line break).

HTML Attributes
 All HTML elements can have attributes
 Attributes provide additional information about an element
 Attributes are always specified in the start tag
 Attributes usually come in name/value pairs like: name="value"

The href Attribute

HTML links are defined with the <a> tag. The link address is specified in the href attribute
Example
<a href="https://www.w3schools.com">This is a link</a>

HTML Headings

Headings are defined with the <h1> to <h6> tags.

<h1> defines the most important heading. <h6> defines the least important heading.

Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Output:

Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6

HTML Paragraphs

The HTML <p> element defines a paragraph:

Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

HTML Block and Inline Elements

Every HTML element has a default display value depending on what type of element it is.

The two display values are: block and inline.


Block-level Elements

A block-level element always starts on a new line and takes up the full width available (stretches out
to the left and right as far as it can).

The <div> element is a block-level element.

Example
<div>Hello World</div>

Block level elements in HTML:

1. <address>
2. <article>
3. <aside>
4. <blockquote>
5. <canvas>
6. <dd>
7. <div>
8. <dl>
9. <dt>
10. <fieldset>
11. <figcaption>
12. <figure>
13. <footer>
14. <form>
15. <h1>-<h6>
16. <header>
17. <hr>
18. <li>
19. <main>
20. <nav>
21. <noscript>
22. <ol>
23. <p>
24. <pre>
25. <section>
26. <table>
27. <tfoot>
28. <ul>
Inline Elements

An inline element does not start on a new line and only takes up as much width as necessary.

This is an inline <span> element inside a paragraph.

Example
<span>Hello World</span>

Inline elements in HTML:

1. <a>
2. <abbr>
3. <acronym>
4. <b>
5. <bdo>
6. <big>
7. <br>
8. <button>
9. <cite>
10. <code>
11. <dfn>
12. <em>
13. <i>
14. <img>
15. <input>
16. <kbd>
17. <label>
18. <map>
19. <object>
20. <output>
21. <q>
22. <samp>
23. <script>
24. <select>
25. <small>
26. <span>
27. <strong>
28. <sub>
29. <sup>
30. <textarea>
31. <time>
32. <tt>
33. <var>

The <div> Element

The <div> element is often used as a container for other HTML elements.

The <div> element has no required attributes, but style, class and id are common.

When used together with CSS, the <div> element can be used to style blocks of content:

Example
<div style="background-color:black;color:white;padding:20px;">
<h2>London</h2> <p>London is the capital city of England. It is the most populous
city.UnitedKingdom, with a metropolitan area of over 13 million inhabitants.</p></div>

1.2 CSS:-

What is CSS?
 CSS stands for Cascading Style Sheets
 CSS describes how HTML elements are to be displayed on screen, paper, or in other media
 CSS saves a lot of work. It can control the layout of multiple web pages all at once
 External stylesheets are stored in CSS files

CSS Syntax

A CSS rule-set consists of a selector and a declaration block:

The selector points to the HTML element you want to style.


The declaration block contains one or more declarations separated by semicolons.

Each declaration includes a CSS property name and a value, separated by a colon.

A CSS declaration always ends with a semicolon, and declaration blocks are surrounded by curly
braces.

Example
In this example all <p> elements will be center-aligned, with a red text color:

p{
color: red;
text-align: center;
}

CSS Selectors

CSS selectors are used to "find" (or select) the HTML elements you want to style.

We can divide CSS selectors into five categories:

 Simple selectors (select elements based on name, id, class)


 Combinator selectors (select elements based on a specific relationship between them)
 Pseudo-class selectors (select elements based on a certain state)
 Pseudo-elements selectors (select and style a part of an element)
 Attribute selectors (select elements based on an attribute or attribute value)

This page will explain the most basic CSS selectors.

The CSS element Selector

The element selector selects HTML elements based on the element name.

Example

Here, all <p> elements on the page will be center-aligned, with a red text color:

p{
text-align: center;
color: red;
}

The CSS id Selector

The id selector uses the id attribute of an HTML element to select a specific element.

The id of an element is unique within a page, so the id selector is used to select one unique element!

To select an element with a specific id, write a hash (#) character, followed by the id of the element.
Example
The CSS rule below will be applied to the HTML element with id="para1":

#para1 {
text-align: center;
color: red;
}
Note: An id name cannot start with a number!

The CSS class Selector

The class selector selects HTML elements with a specific class attribute.

To select elements with a specific class, write a period (.) character, followed by the class name.

Example

In this example all HTML elements with class="center" will be red and center-aligned:

.center {
text-align: center;
color: red;
}

How To Add CSS

When a browser reads a style sheet, it will format the HTML document according to the information
in the style sheet.

Three Ways to Insert CSS

There are three ways of inserting a style sheet:

 External CSS
 Internal CSS
 Inline CSS
External CSS

With an external style sheet, you can change the look of an entire website by changing just one file!

Each HTML page must include a reference to the external style sheet file inside the <link> element,
inside the head section.

Example
External styles are defined within the <link> element, inside the <head> section of an HTML page:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

An external style sheet can be written in any text editor, and must be saved with a .css extension.

The external .css file should not contain any HTML tags.

Here is how the "mystyle.css" file looks like:

"mystyle.css"
body {
background-color: lightblue;
}

h1 {
color: navy;
margin-left: 20px;
}
Note: Do not add a space between the property value and the unit (such as margin-left: 20 px;). The
correct way is: margin-left: 20px;

Internal CSS

An internal style sheet may be used if one single HTML page has a unique style.

The internal style is defined inside the <style> element, inside the head section.
Example

Internal styles are defined within the <style> element, inside the <head> section of an HTML page:

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: linen;
}

h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Inline CSS

An inline style may be used to apply a unique style for a single element.

To use inline styles, add the style attribute to the relevant element. The style attribute can contain any
CSS property.

Example

Inline styles are defined within the "style" attribute of the relevant element:

<!DOCTYPE html>
<html>
<body>

<h1 style="color:blue;text-align:center;">This is a heading</h1>


<p style="color:red;">This is a paragraph.</p>
</body>
</html>
hbjkk
1.3 Javascript:-

1. A scripting language is a lightweight programming language.


2. JavaScript is programming code that can be inserted into HTML pages.

3. JavaScript code can be executed by all modern web browsers.

4. JavaScript is easy to learn.

The <script> Tag

1. To insert a JavaScript into an HTML page, use the <script> tag.


2. The <script> and </script> tells where the JavaScript starts and ends.

3. The lines between the <script> and </script> contain the JavaScript:

<script>
alert("My First JavaScript");
</script>

JavaScript in <body>

In this example, JavaScript writes into the HTML <body> while the page loads:

Example
<!DOCTYPE html>
<html>
<body>
.
.
<script>
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
</script>
.
.
</body>
</html>

JavaScript Statement
JavaScript is a sequence of statements to be executed by the browser.

JavaScript Statements

JavaScript statements are "commands" to the browser.

The purpose of the statements is to tell the browser what to do.

This JavaScript statement tells the browser to write "Hello Dolly" inside an HTML element with
id="demo":

document.getElementById("demo").innerHTML="Hello Dolly";

Semicolon ;

Semicolon separates JavaScript statements.

Normally you add a semicolon at the end of each executable statement.

Using semicolons also makes it possible to write many statements on one line.

You might see examples without semicolons.


Ending statements with semicolon is optional in JavaScript.

JavaScript Code

JavaScript code (or just JavaScript) is a sequence of JavaScript statements.

Each statement is executed by the browser in the sequence they are written.

This example will manipulate two HTML elements:

Example
document.getElementById("demo").innerHTML="Hello Dolly";
document.getElementById("myDIV").innerHTML="How are you?";

JavaScript Comments

Comments will not be executed by JavaScript.

Comments can be added to explain the JavaScript, or to make the code more readable.

Single line comments start with //.


Multi line comments start with /* and end with */.

JavaScript Variables:-

JavaScript variables are "containers" for storing information:

Example
var x=5;
var y=6;
var z=x+y;

JavaScript Data Types

String, Number, Boolean, Array, Object, Null, Undefined.

JavaScript Has Dynamic Types

JavaScript has dynamic types. This means that the same variable can be used as different types:

Example
var x; // Now x is undefined
var x = 5; // Now x is a Number
var x = "John"; // Now x is a String

JavaScript Functions

A function is a block of code that will be executed when "someone" calls it:

Example
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction()
{
alert("Hello World!");
}
</script>
</head>

<body>
<button onclick="myFunction()">Try it</button>
</body>
</html>

JavaScript Function Syntax

A function is written as a code block (inside curly { } braces), preceded by the function keyword:

function functionname()
{
some code to be executed
}

The code inside the function will be executed when "someone" calls the function.

The function can be called directly when an event occurs (like when a user clicks a button), and it can
be called from "anywhere" by JavaScript code.

JavaScript is case sensitive. The function keyword must be written in lowercase letters, and the function must be
with the same capitals as used in the function name.

Calling a Function with Arguments

When you call a function, you can pass along some values to it, these values are
called arguments or parameters.

These arguments can be used inside the function.

You can send as many arguments as you like, separated by commas (,)

myFunction(argument1,argument2)

Declare the argument, as variables, when you declare the function:

function myFunction(var1,var2)
{
some code
}

The variables and the arguments must be in the expected order. The first variable is given the value of
the first passed argument etc.

Example
<button onclick="myFunction('Harry Potter','Wizard')">Try it</button>

<script>
function myFunction(name,job)
{
alert("Welcome " + name + ", the " + job);
}
</script>

Functions With a Return Value

Sometimes you want your function to return a value back to where the call was made.

This is possible by using the return statement.

When using the return statement, the function will stop executing, and return the specified value.

Syntax
function myFunction()
{
var x=5;
return x;
}

1.4 Sql:-

What is SQL?
 SQL stands for Structured Query Language
 SQL lets you access and manipulate databases
 SQL is an ANSI (American National Standards Institute) standard

What Can SQL do?


 SQL can execute queries against a database
 SQL can retrieve data from a database
 SQL can insert records in a database
 SQL can update records in a database
 SQL can delete records from a database
 SQL can create new databases
 SQL can create new tables in a database
 SQL can create stored procedures in a database
 SQL can create views in a database
 SQL can set permissions on tables, procedures, and views

Some of The Most Important SQL Commands


 SELECT - extracts data from a database
 UPDATE - updates data in a database
 DELETE - deletes data from a database
 INSERT INTO - inserts new data into a database
 CREATE DATABASE - creates a new database
 ALTER DATABASE - modifies a database
 CREATE TABLE - creates a new table
 ALTER TABLE - modifies a table
 DROP TABLE - deletes a table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index

The SQL SELECT Statement

 The SELECT statement is used to select data from a database.


 The result is stored in a result table, called the result-set.

SQL SELECT Syntax


SELECT column_name,column_name
FROM table_name;

and

SELECT * FROM table_name;

The SQL SELECT DISTINCT Statement

In a table, a column may contain many duplicate values; and sometimes you only want to list the
different (distinct) values.

The DISTINCT keyword can be used to return only distinct (different) values.

SQL SELECT DISTINCT Syntax


SELECT DISTINCT column_name,column_name
FROM table_name;

The SQL WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.

SQL WHERE Syntax


SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;

The SQL AND & OR Operators

The AND operator displays a record if both the first condition AND the second condition are true.

The OR operator displays a record if either the first condition OR the second condition is true.
The SQL ORDER BY Keyword

The ORDER BY keyword is used to sort the result-set by one or more columns.

The ORDER BY keyword sorts the records in ascending order by default. To sort the records in a
descending order, you can use the DESC keyword.

SQL ORDER BY Syntax


SELECT column_name,column_name
FROM table_name
ORDER BY column_name,column_name ASC|DESC;

The SQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.

SQL INSERT INTO Syntax

It is possible to write the INSERT INTO statement in two forms.

The first form does not specify the column names where the data will be inserted, only their values:

INSERT INTO table_name


VALUES (value1,value2,value3,...);

The second form specifies both the column names and the values to be inserted:

INSERT INTO table_name (column1,column2,column3,...)


VALUES (value1,value2,value3,...);

The SQL UPDATE Statement

The UPDATE statement is used to update existing records in a table.

SQL UPDATE Syntax


UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;

SQL DELETE Syntax


DELETE FROM table_name
WHERE some_column=some_value;

Notice the WHERE clause in the SQL DELETE statement!


The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all r
will be deleted!

The SQL LIKE Operator

The LIKE operator is used to search for a specified pattern in a column.

SQL LIKE Syntax


SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;

SQL INNER JOIN Keyword

The INNER JOIN keyword selects all rows from both tables as long as there is a match between the
columns in both tables.

SQL INNER JOIN Syntax


SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;

or:

SELECT column_name(s)
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;

PS! INNER JOIN is the same as JOIN.


SQL LEFT JOIN Keyword

The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the
right table (table2). The result is NULL in the right side when there is no match.

SQL LEFT JOIN Syntax


SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;

or:

SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;

PS! In some databases LEFT JOIN is called LEFT OUTER JOIN.

SQL RIGHT JOIN Keyword

The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the
left table (table1). The result is NULL in the left side when there is no match.

SQL RIGHT JOIN Syntax


SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;

or:

SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;

PS! In some databases RIGHT JOIN is called RIGHT OUTER JOIN.


SQL FULL OUTER JOIN Keyword

The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table
(table2).

The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.

SQL FULL OUTER JOIN Syntax


SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;

The SQL CREATE DATABASE Statement

The CREATE DATABASE statement is used to create a database.

SQL CREATE DATABASE Syntax


CREATE DATABASE dbname;

SQL CREATE DATABASE Example

The following SQL statement creates a database called "my_db":

CREATE DATABASE my_db;


The SQL CREATE TABLE Statement

The CREATE TABLE statement is used to create a table in a database.

Tables are organized into rows and columns; and each table must have a name.

SQL CREATE TABLE Syntax


CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);

The column_name parameters specify the names of the columns of the table.

The data_type parameter specifies what type of data the column can hold (e.g. varchar, integer,
decimal, date, etc.).

The size parameter specifies the maximum length of the column of the table.

The SQL BETWEEN Operator

The BETWEEN operator selects values within a range. The values can be numbers, text, or dates.

SQL BETWEEN Syntax


SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

SQL Aggregate Functions

SQL aggregate functions return a single value, calculated from values in a column.

Useful aggregate functions:

 AVG() - Returns the average value


 COUNT() - Returns the number of rows
 FIRST() - Returns the first value
 LAST() - Returns the last value
 MAX() - Returns the largest value
 MIN() - Returns the smallest value
 SUM() - Returns the sum
1.5 PHP:-

What You Should Already Know

Before you continue you should have a basic understanding of the following:

 HTML
 CSS
 JavaScript

If you want to study these subjects first, find the tutorials on our Home page.

What is PHP?
 PHP is an acronym for "PHP Hypertext Preprocessor"
 PHP is a widely-used, open source scripting language
 PHP scripts are executed on the server
 PHP costs nothing, it is free to download and use

PHP is simple for beginners.

PHP also offers many advanced features for professional programmers.

What is a PHP File?


 PHP files can contain text, HTML, CSS, JavaScript, and PHP code
 PHP code are executed on the server, and the result is returned to the browser as plain HTML
 PHP files have extension ".php"

What Can PHP Do?


 PHP can generate dynamic page content
 PHP can create, open, read, write, and close files on the server
 PHP can collect form data
 PHP can send and receive cookies
 PHP can add, delete, modify data in your database
 PHP can restrict users to access some pages on your website
 PHP can encrypt data

With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash
movies. You can also output any text, such as XHTML and XML.
Why PHP?
 PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
 PHP is compatible with almost all servers used today (Apache, IIS, etc.)
 PHP supports a wide range of databases
 PHP is free. Download it from the official PHP resource: www.php.net
 PHP is easy to learn and runs efficiently on the server side

Basic PHP Syntax

A PHP script can be placed anywhere in the document.

A PHP script starts with <?php and ends with ?>:

<?php
// PHP code goes here
?>

The default file extension for PHP files is ".php".

A PHP file normally contains HTML tags, and some PHP scripting code.

Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function
"echo" to output the text "Hello World!" on a web page:

Example
<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html>

PHP 5 Variables

Variables are "containers" for storing information:

Example
<?php
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>
PHP echo and print Statements

There are some differences between echo and print:

 echo - can output one or more strings


 print - can only output one string, and returns always 1

Tip: echo is marginally faster compared to print as echo does not return any value.

PHP Data Types

String, Integer, Floating point numbers, Boolean, Array, Object, NULL.

PHP Functions

The real power of PHP comes from its functions; it has more than 1000 built-in functions.

PHP User Defined Functions

Besides the built-in PHP functions, we can create our own functions.

A function is a block of statements that can be used repeatedly in a program.

A function will not execute immediately when a page loads.

A function will be executed by a call to the function.

Create a User Defined Function in PHP

A user defined function declaration starts with the word "function":

Syntax
function functionName()
{
code to be executed;
}

Note: A function name can start with a letter or underscore (not a number).

Tip: Give the function a name that reflects what the function does!

Remember that function names are case-insensitive.


In the example below, we create a function named "writeMsg()". The opening curly brace ( { )
indicates the beginning of the function code and the closing curly brace ( } ) indicates the end of the
function. The function outputs "Hello world!". To call the function, just write its name:

Example
<?php
function writeMsg()
{
echo "Hello world!";
}

writeMsg(); // call the function


?>

PHP Function Arguments

Information can be passed to functions through arguments. An argument is just like a variable.

Arguments are specified after the function name, inside the parentheses. You can add as many
arguments as you want, just seperate them with a comma.

The following example has a function with one argument ($fname). When the familyName() function
is called, we also pass along a name (e.g. Jani), and the name is used inside the function, which
outputs several different first names, but an equal last name:

Example
<?php
function familyName($fname)
{
echo "$fname Refsnes.<br>";
}

familyName("Jani");
familyName("Hege");
familyName("Stale");
familyName("Kai Jim");
familyName("Borge");
?>

The following example has a function with two arguments ($fname and $year):

Example
<?php
function familyName($fname,$year)
{
echo "$fname Refsnes. Born in $year <br>";
}

familyName("Hege","1975");
familyName("Stale","1978");
familyName("Kai Jim","1983");
?>

PHP Default Argument Value

The following example shows how to use a default parameter. If we call the function setHeight()
without arguments it takes the default value as argument:

Example
<?php
function setHeight($minheight=50)
{
echo "The height is : $minheight <br>";
}

setHeight(350);
setHeight(); // will use the default value of 50
setHeight(135);
setHeight(80);
?>

PHP Functions - Returning values

To let a function return a value, use the return statement:

Example
<?php
function sum($x,$y)
{
$z=$x+$y;
return $z;
}

echo "5 + 10 = " . sum(5,10) . "<br>";


echo "7 + 13 = " . sum(7,13) . "<br>";
echo "2 + 4 = " . sum(2,4);
?
Chaper2

RESULTS AND DISCUSSION

 The industrial training that i went though within the last few months brought in new
technologies and expanded my knownledge in the IT industry.
 I got the opportunity to put known concept in to paratice and leran new concepts through
applying them.
 Meeting with deadlines,keeping the code quality,trying various approach to determine the
best method and finally completing the project with success were experience that gained
throughout the training period.

 Also during the training I learn that it is always good to try new things like learn new
technologies and languages rather than only sticking to the things I know best.


Chapter 3

Conclusion

 PHP is a great tool for writing dynamic web pages. Non-technical users can easily learn a few
handy tricks to make their web pages easier to manage, and more useful. Because its syntax
resembles most C-like languages, any Computer Science student is able to learn it very quickly.

 When creating a PHP enhanced pages, there are a few things we must remember.PHP is a
server side technology, and does not work in a browser. The filename must have .php
extension.PHP enhanced pages can contain a mixture of HTML and PHP code.PHP code must
be enclosed in <?php?> tag.

 For more PHP information and tips, please visit php.net, or do a web search. You'll find tons of
PHP-related material. Happy coding! Do you want your Perl code on one server to call your
PHP functions on another? "Impossible!" you say? Not with XML-RPC. XML-RPC is a standard
way for any application to make requests and receive responses from methods write
Reference:

• www.php.net
• Wikipedia
• http://www.w3schools.com/
• http://patrickhurley.wordpress.com/mysql-for-oracle-dba

om Page 8

You might also like