Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
calculator-php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
dev-courses
calculator-php
Commits
81cb21f6
Commit
81cb21f6
authored
Oct 15, 2016
by
Vadym Gidulian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
index.php
index.php
+56
-0
No files found.
index.php
0 → 100644
View file @
81cb21f6
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
PHP Calculator
</title>
</head>
<body>
<?php
if
(
!
empty
(
$_POST
[
'op1'
])
&&
!
empty
(
$_POST
[
'op2'
])
&&
!
empty
(
$_POST
[
'op'
]))
{
$op1
=
$_POST
[
'op1'
];
$op2
=
$_POST
[
'op2'
];
$op
=
$_POST
[
'op'
];
switch
(
$op
)
{
case
'plus'
:
$result
=
$op1
+
$op2
;
break
;
case
'minus'
:
$result
=
$op1
-
$op2
;
break
;
case
'mul'
:
$result
=
$op1
*
$op2
;
break
;
case
'div'
:
$result
=
$op1
/
$op2
;
break
;
}
}
?>
<form
action=
"index.php"
method=
"post"
>
<input
type=
"number"
name=
"op1"
>
<select
name=
"op"
>
<option
value=
"plus"
>
+
</option>
<option
value=
"minus"
>
-
</option>
<option
value=
"mul"
>
*
</option>
<option
value=
"div"
>
/
</option>
</select>
<input
type=
"number"
name=
"op2"
>
<button
type=
"submit"
>
Calculate
</button>
</form>
<?php
if
(
!
empty
(
$result
))
:
?>
<p>
Result:
<?php
echo
$result
;
?>
</p>
<?php
endif
;
?>
<footer
style=
"margin-top: 25px;"
>
©
WDC 2015-
<?php
echo
date
(
'Y'
);
?>
</footer>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment