3. Nikhil Joshi
3
Backgounrd
• PHP is server side scripting system
– PHP stands for "PHP: Hypertext
Preprocessor"
– Syntax based on Perl, Java, and C
– Very good for creating dynamic
content
– Powerful, but somewhat risky!
4. Nikhil Joshi
4
PHP is a server-side scripting language designed primarily for web development but
Is also used as a general purpose programming language. Originally created by
Rasmus Lerdorf in 1994
Developer of PHP IS Zend Technologies
Latest version of PHP is 7.0.10
5. Nikhil Joshi
5
Syntax of PHP
<html>
<head>
<title> Example </title>
</head>
<body>
<?php
echo “hi, I’m a php script”;
?>
</body>
</html>
6. Nikhil Joshi
6
Layout
Layout can be designed using 2 ways :-
• Tabular
• Division
Tabular- Area taken on the basis of <tr> <td> tags.
Division- Division is area taken by <div> on the web pages
but it is invisible itself as long as you defines it’s border or
background.
7. Nikhil Joshi
7
CSS
It is used mainly for desining in Webpage.
3 Types of CSS
• Inline
• Internal
• External
8. Nikhil Joshi
8
Inline - within a line that is inline that is inline CSS is used within the
line of HTML tag and it’s syntax is :-
<tag_name Style=“at:value;at2value;a+3value”>
<p style=“color:red;font-size:50px;backgroundcolor:green”>Nikhil</p>
External - External CSS is maintained on the extra sheet and save this page with
.css extention and link this CSS to the particular html page
<link REL="STYLESHEET" TYPE="text/css" HREF="[Style sheet URL]">
Internal - An internal stylesheet holds the CSS code for the webpage in the
head section of the particular file. This makes it easy to apply styles
like classes or id's in order to reuse the code.
<style> p { font-size: 20px; font-weight: bold; } </style>
9. Nikhil Joshi
9
Selectors
• Id Universal
• Class parent/child Hierarchial
• Element(Tag) pseudo selector(Event like hover)
Id- Id selector is used in a HTML by using Id attribute like
<p id=“one”>Ram</p>
<p id=“two”>Mohan</p>
<p id=“three”>Sohan</p>
And maintain the Id using CSS by using # symbol with id name
10. Nikhil Joshi
10
Class Selector
The working of class selector is similar like Id selecetor but difference is that in place
Of Id.We use class in html tag & in place of # symbol we use . Symbol in a CSS.
Element Selector
Element selector is directly taken by it’s tag name that’swhy it is also known
tag selector.
11. Nikhil Joshi
11
Universal Selector
Universal Selector is applicable globally on the whole pages & it is maintained
In CSS using abstract symbol in CSS.
Parent/child Selector
<html>
<head>
</head>
<body>
<ul>
<li> oil </li>
</ul>
<ol>
<li> oil </li>
</ol>
</body>
</head>
</html>
12. Nikhil Joshi
12
Pseudo Selector
It is used for mainly perform events.
one.css
Ol li
{
color:red;
fontsize: 40px;
background_color:green;
}
Ol li:hover
{
color:yellow;
fontsize:20px;
}
13. Nikhil Joshi
13
Control Statements
There are 3 types of control statements
1) if Statement
2) if else Statement
3) if else if Statement
If Statement
If (expression)
{
code to be executed
}
<html>
<head>
</head>
<body>
<script>
var a=40;
if(a>20)
14. Nikhil Joshi
14
{
Document.write(“value is greater than 20”)
}
</script>
</body>
</html>
It evaluates the content only if the expression is true.
If else Statement
It evaluates the content wether the condition is true or false
If(expression)
{
Code to be executed
}
Else
{
}
16. Nikhil Joshi
16
If else if Statement
It evaluates the content only if expression is true from several conditions
If(expresssion 1)
{
}
elseif(expression 2)
{
}
elseif(expression 3)
{
}
else
{
}
18. Nikhil Joshi
18
Strings
A String is a sequence of characters used to store and manipulate texts.
There are various functions to manipulate strings
• Strrev() This function is used to check the palindrome series of names and characters
<html>
<head>
</head>
<body>
<?php
$a=“nitin”;
if(strrev($a)==$a)
{
echo”name is palindrome”;
}
else
{
echo”name is not palindrome”;
}
?>
</body>
</html>
19. Nikhil Joshi
19
• Str_repeat()- If we want to repeat the object of the strings number of times then
we use string repeat function.
<html>
<head>
</head>
<body>
<?php
$a=“welcome”;
echo str_repeat($a,4);
?>
</body>
</html>
• Str_replace()- It is used to replace the characters
<html>
<head>
</head>
<body>
<?php
$a=“welcome”;
echo str_replace(“e”,”@”,$a);
?>
</body>
</html>
20. Nikhil Joshi
20
• Str_word_count() – It is used to count the number of words in a string
<html>
<head>
</head>
<body>
<?php
$a=“welcome to the world of php”;
echo str_word_count($a);
?>
</body>
</html>
• Strcmp() – This function is used to compare the 2 strings
<html>
<head>
</head>
<body>
<?php
$a=“hello”;
$a1=“hello”;
echo strcmp($a,$a1)
?>
</body>
</html>
22. Nikhil Joshi
22
File Handling In PHP
The file system functions allow us to acess and manipulate the file.File system provides a concept
to start a specific data using different types of file format.that means file give us linear type
database concept.
• How to create a file via PHP
The touch function is used to create a file
<?php
touch(“resume.doc”);
touch(“a.pdf”);
touch(“b.txt”);
?>
• How can we delete a file via PHP code
The Unlink function is used to delete a file.
<?php
unlink(“resume.doc”);
unlink(“a.pdf”);
unlink(“b.txt”);
?>
• How can we copy a file by PHP
The copy function is used to copy a file.
<?php
copy(“name of file with extention,name of destination file with etension”);
?>
23. Nikhil Joshi
23
• How can we rename a gift by PHP code
Rename function is used to rename a file.
<?php
rename(“name of file with extension”)
?>
• How can we check whether a file or a destination file is exist or not
The file_exist function is used to check the file or directory existance
<?php
echo file_exists(“resume.doc”);
?>
• How can we check the size of the file by php code
filesize function is used to check the size of the file
<?php
echo filesize(“resume.doc”);
?>
• How can we check the path of the file.
realpath function is used to check the path of the file
<?php
echo realpath(“resume.doc”);
?>