Você está na página 1de 25

CONTENTS:

WHAT IS PHP?
WHAT YOU CAN DO WITH PHP
ADVANTAGES OF PHP
GETTING STARTED WITH PHP
STANDARD PHP SYNTAX
DATA TYPES IN PHP
OPERATORS IN PHP
CONCEPT OF ARRAY IN PHP
GETTING STARTED WITH HTML
WHAT IS CSS?
USING SQL
1. What is PHP?
PHP stands for preprocessor hypertext page.
PHP is a powerful and widely used open source
server-side scripting language to generate a web
page.
PHP scripts are executed on the server and the result
is sent to the browser as plain HTML.
PHP can be integrated with number of popular
database, including MySQL,Oracle etc.
PHP can be embedded within normal HTML web
pages.

2. What you can do with PHP?


You can generate dynamic pages and files.
You can create, open, read, write and close files on
server.
You can send emails to the users of the website.
You can store, delete, and modify information in
your database.
You can encrypt data for safe transmission over
internet.

3. Advantages of PHP
Easy to learn: PHP is easy to learn and use. For
beginner programmers who just started out in web
development, PHP is often considered as the best
and preferable choice of scripting language to learn.
Open source: PHP is an open source project-the
language is developed and maintained by a
worldwide community of developers who makes its
source code freely available to download and use.
There are no costs associated with using PHP for
individual or commercial projects, including future
updates.
Portability: PHP runs on various platforms such as
Microsoft Windows, Linux, Mac OS, etc. and it is
compatible with almost all servers used today such
Apache , IIS, etc.
Fast Performance: Scripts written in PHP usually
execute faster than those written in other scripting
like APS.NET or JSP.
Vast Community: Since PHP is supported by the
worldwide community, finding help or
documentation for PHP online is extremely easy.

4. Getting Started With PHP


Before begin, be sure to have a PHP script execute on a
web server running PHP. So before you start writing any
PHP program you need the following programs installed
on your PC.

The Apache web server.


The PHP engine

The MYSQL database server.


Or

Install JDK (Java Development Kit).

Install XAMP/WAMP/LINUX.
Install net beans.

5. STANDARD PHP SYNTAX


STANDARD PHP EXPLANATION
SYNTAX
<?php PHP script starts with this syntax.

?> PHP script ends with this syntax.

echohello,world; ECHO is used to print the result in output

;(semicolon) This tells the PHP engine that the end of c


statement has been reached.
<br> This is used to break the lines in the
Result.
$(dollar) All variable in PHP start with a $ sign,
followed by the name of the variable.
print or print() It is just like echo syntax i.e. used to
display output to the browser but this can
only output one string, and always returns
1.
gettype() It is used to get the type of the data.

6. DATA TYPES IN PHP


Data types are the entity which tells us about the types
of data we are going to store. There are basically 6 data
types in PHP.
INTEGER-used to store non decimal values.
DOUBLE-used to store friction values.
STRING-used to store alphanumeric values.
BOOLEAN-it can store possibly true and false.
ARRAY-collection of mixed values.
OBJECT- reference to class.

7. OPERATORS IN PHP
There are set of symbols which are used to perform
some operations.
ARITHMETIC OPRATOR-which is used to
add(+),subtract(-),multiply(*),divide(/),modulus(%) .
RELATIONAL/COMPARISION-are used to give relation
or comparison of two values with each other like
smaller than(<),greater than(>),smaller or equal
to(<=),greater or equal to(>=),equal to(==),not equal
to(!=).
ASSIGNMENT OPERATOR it is used to assign the
value to the variable like increment equal
to(+=),decrement equal to(-=),multiply equal
to(*=),divide equal to(/=).
INCREMENT/DECREMENT- increment (++) is used to
increase any value by 1.
Decrement (--) is used to decrease any value by 1.
CONDITIONAL/TERNARY-it will check for given
condition if condition is true expression 1 get
executed otherwise expression 2 get executed like
(Condition?expression1:expression2);
LOGICAL-these are used to combine two or more
conditions and get a common output. And symbols
are logical and (&&), logical or (||), logical not (!).
SPECIAL-these are special purpose operators which
are rarely used. Concatenate(.),associative(=>) and
reference(->)
8. CONCEPT OF ARRAY IN PHP
ARRAY:
It is the collection of mixed types of data and values
or we can say an array is a data structure that stores
one more similar type of values in a single value. For
example if we want to store 100 numbers then
instead of defining 100 variables its easy to define
an array of 100 lengths.
There are three different kinds of arrays and each
array value is accessed using an ID c which is called
array index.
Numeric array- An array with a numeric index.
Values are stored and accessed in linear fashion.
These arrays can store numbers, strings, and any
object but their index will be represented by
numbers. By default array index starts from zero.
EXAMPLE:

<html>

<body>
<?php

/* First method to create array. */

$numbers = array( 1, 2, 3, 4, 5);

foreach( $numbers as $value ) {

echo "Value is $value <br />";

/* Second method to create array. */

$numbers[0] = "one";

$numbers[1] = "two";

$numbers[2] = "three";

$numbers[3] = "four";

$numbers[4] = "five";

foreach( $numbers as $value ) {

echo "Value is $value <br />";

?>
</body>

</html>

This will produce the following result

Value is 1
Value is 2
Value is 3
Value is 4
Value is 5
Value is one
Value is two
Value is three
Value is four
Value is five

Associative array- An array with strings as


index. This stores element values in association
with key values rather than in a strict linear
index order. The associative arrays are very
similar to numeric arrays in term of functionality
but they are different in terms of their index.
Associative array will have their index as string
so that you can establish a strong association
between key and values.

To store the salaries of employees in an array, a


numerically indexed array would not be the best choice.
Instead, we could use the employees names as the keys in
our associative array, and the value would be their
respective salary.

EXAMPLE:

<html>

<body>

<?php

/* First method to associate create array.


*/

$salaries = array("mohammad" => 2000,


"qadir" => 1000, "zara" => 500);

echo "Salary of mohammad is ".


$salaries['mohammad'] . "<br />";
echo "Salary of qadir is ".
$salaries['qadir']. "<br />";

echo "Salary of zara is ".


$salaries['zara']. "<br />";

/* Second method to create array. */

$salaries['mohammad'] = "high";

$salaries['qadir'] = "medium";

$salaries['zara'] = "low";

echo "Salary of mohammad is ".


$salaries['mohammad'] . "<br />";

echo "Salary of qadir is ".


$salaries['qadir']. "<br />";

echo "Salary of zara is ".


$salaries['zara']. "<br />";

?>

</body>

</html>

This will produce the following result


Salary of mohammad is 2000
Salary of qadir is 1000
Salary of zara is 500
Salary of mohammad is high
Salary of qadir is medium
Salary of zara is low

Multimensional array- An array containing one or


more arrays and values are accessed using multiple
indices. A multi-dimensional array each element in
the main array can also be an array. And each
element in the sub-array can be an array, and so on.
Values in the multi-dimensional array are accessed
using multiple indexes.
EXAMPLE:

<html>

<body>

<?php

$marks = array(
"mohammad" => array (

"physics" => 35,

"maths" => 30,

"chemistry" => 39

),

"qadir" => array (

"physics" => 30,

"maths" => 32,

"chemistry" => 29

),

"zara" => array (

"physics" => 31,

"maths" => 22,

"chemistry" => 39

);
/* Accessing multi-dimensional array values
*/

echo "Marks for mohammad in physics : " ;

echo $marks['mohammad']['physics'] . "<br


/>";

echo "Marks for qadir in maths : ";

echo $marks['qadir']['maths'] . "<br />";

echo "Marks for zara in chemistry : " ;

echo $marks['zara']['chemistry'] . "<br />";

?>

</body>

</html>

This will produce the following result

Marks for mohammad in physics : 35


Marks for qadir in maths : 32
Marks for zara in chemistry : 39
9. GETTING STARTED WITH HTML
The full form of HTML is Hyper Text Markup
Language.
Where markup is denoted by (<>) this symbol.
It is an error free language.
It is the combination of text and attributes.
It works on every browser.
Its extension is .html or .htm.
There are two types of tags in html.
Singular-it is not essential to close the tag.
Plural- it is essential to close the tags.

8.1.SYNTAX OF HTML
TAG/SYNTAX SHORT DESCRIPTION
<html></html> Main container.

<head></head> The documents header.

<title></title> The documents title.

<body></body> The documents body.

<h1><h2><h3><h4><h5><h6> 1 to 6 level of heading.

<p> Paragraph.

<img src=> Insert image to your web page.

<font> Will change font size ,color and style.

<hr> Horizontal rule.

<br> Break the line.

<table> Will insert the table.

<marquee> Scrolling text

<li> List items

<ahref=> Link two or more pages together.

EXAMPLE :
<HTML>
<HEAD>
<TITLE>Your Title Here</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<CENTER><IMG SRC="clouds.jpg" ALIGN="BOTTOM"> </CENTER>
<HR>
<a href="http://somegreatsite.com">Link Name</a>
is a link to another nifty site
<H1>This is a Header</H1>
<H2>This is a Medium Header</H2>
Send me mail at <a href="mailto:support@yourcompany.com">
support@yourcompany.com</a>.
<P> This is a new paragraph!
<P> <B>This is a new paragraph!</B>
<BR> <B><I>This is a new sentence without a paragraph break, in bold
italics.</I></B>
<HR>
</BODY>
</HTML>
And the result of the above programming is:
9.WHAT IS CSS?
CSS stands for cascading style sheets.
CSS describes how HTML elements are to be
displayed on screen, or in other media.
CSS saves a lot of work. It can control the layout of
multiple web pages all at once.
CSS is used to style and layout web pages-for
example, to alter the font, colour, size and spacing of
content, split into multiple columns, add animations
and other decorative features.
CSS contain two main parts i.e. selector and
declaration.

CSS syntax is always under <style> </style> style tags


which is under <head></head> heading tags.
CSS extension is file name.css.

9.1.SOME EXAMPLE OF CSS


10.ABOUT SQL
SQL stands for Structured Query Language.
My SQL deals with three query
DDL-(Data Definition Language).It is used to create,
alter and drop the data in the table. It deals with the
outer structure of table.
DML-(Data Manipulation Language).It is used to
insert, update and delete the data. It deals with the
actual data in the table.
DQL-(Data Query Language).It is used to select t he
data. It queries the data.

10.1.SYNTAX OF MYSQL
For creating table:
create table tablename(columnname
datatype(size),columnname datatype(size),columnname
datatypes(size);
For dropping table:
drop table tablename;
alter table tablename drop columnname;
For altering table:
alter table tablename add new columnname
datatypes(size);
alter table tablename modify columnname
newdatatypes(new size);
For inserting table:
Partial insert:-
insert into tablename(columnname)
values(value1,value2);
Full insert:-
Insert into tablename(value1,value2,value3);
For deleting table:
delete from tablename where condition;
For updating table:
update tablename set columnname=new value where
condition;
For selecting table:
Select * from the table;
Select * from the tablename where condition;
Select columnname,columnname from tablename where
condition;
REFRENCES:
1. www.google.com
2. www.wikipedia.com.

Você também pode gostar