HyperText Preprocessor
It is Previously
called personal home page.
For working
with php there are some softwares
For Linux OS
Users LAMP (Linux Apache My Sql PHP)
FOR Windows
OS Uers WAMP (Windows Apache My Sql PHP)
And for all
OS Common one is XAMPP
(Extensible Apache MySql PHP Perl )
For Working
In Any Type Of OS there are few steps before actual php.
Step 1. Install XAMPP
Step 2. Install Dreamweaver
In
Dreamweaver click on file ->new->Dynamic page->PHP.
You Save
your files in XAMPP ->htdocs->your File name .php
Or
XAMPP
->htdocs->Your Folder (If you create )->your File name .php
And open
your code on browser by
or
php is loosely coupled language or we say that
language +Technology.
Under the HTML
our code of php is running in the
tags of <body> .
<!DOCTYPE html ">
<head>
<title> rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
____________________________________________________
(Code of php)
?>
</body>
</html>
Let we
starts from a simple Example:-
<!DOCTYPE html ">
<head>
<title> rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
echo “Good Morning”;//echo is for
print
?>
</body>
</html>
Our out put
on the Browser is:- Good Morning
---------------------------------------------------------------------------------------------
Operators
Operators
are of Three Types
1.Uniary
(contains of increment
++,decrement--,uniary+,uniary-)
2.Binary
(1.airthmatic
+,-,*,/,%
2. relational
<,>.<=,>=,==,===,!=
3.assignment
=)
3.Ternary
(logical
&&)
Let See Some
Solved Examples :-
Q1. Enter
Two Values And print Substration, Multiplication& devision of two values?
Solution
Code:-
<title>rahuljaincse.blogspot.com</title>
</head>
<body>
<?php
$a=5;
$b=3;
$s=$a-$b;
echo
"substraction is=".$s;
echo"<br>";
$a=5;
$b=3;
$m=$a*$b;
echo
"multiplication is=".$m;
echo"<br>";
$a=5;
$b=3;
$d=$a/$b;
echo
"division is=".$d;
?>
</body>
</html>
Q2.Enter
Radius of circle & print area of circle?
Solution
code:-
<?php
$a=your
radius ;
$c=3.14*$a*$a;
echo"area of circle is".$c;
?>
Q3.Enter
five marks of students and print percentage sheet of student?
<title>
rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
$a=45;
$B=75;
$C=85;
$D=55;
$E=33;
$P=($a+$B+$C+$D+$E)/5;
echo"percentage
of students is =".$P;
?>
</body>
</html>
Q4.Enter any
value and print square and cube of value?
<title>
rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
$a=45;
$sq=$a*$a;
echo"square
is =".$sq."<br>";
$b=45;
$cu=$b*$b*$b;
echo"square
is =".$cu;
?>
</body>
</html>
Q5.Enter Two
values & findout smallest value using ternary operator?
<title>
rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
$a=45;
$b=35;
$comp=($a>$b?$a:$b);
echo"greatest
num is =".$comp;
?>
</body>
</html>
Q6.Enter any
number and find out no. is positive or negative using conditional operation?
</head>
<body>
<?php
$a=45;
con=($a>=0?"pos":"neg");
echo"
num is ".con;
?>
</body>
</html>
Q7.Enter Any
digit & find out digit is single or more than single digit using
conditional operations?
<title>
rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
$a=45;
$con=($a/10=0?"single":"not
single ");
echo"
num is ".$con;
?>
</body>
</html>
Q8.Enter Any
year and find out year is leap year or not leap year?
<title>
rahuljaincse.blogspot.com </title>
</head>
<body>
<?php
$a=2000;
$year=($a%4==0?"leap
year":"non leap year");
echo"year
is=".$year;
?>
</body>
</html>
No comments:
Post a Comment