HTML5
Этот тег определяет метку для элемента.
<?
php
class Symbol {
private $
a
=
null
;
b
symbol
function __construct($arg0, $arg1, $arg2) {
$this->a = $arg0;
$this->b = $arg1;
$this->symbol = $arg2;
}
function getA() {
return $this->a;
function getB() {
return $this->b;
function Result() {
switch($this->symbol) {
case '+' :
echo $this->a, ' + ', $this->b, ' = ', ($this->a + $this->b), '<
br
/>';
break;
case '-' :
echo $this->a, ' - ', $this->b, ' = ', ($this->a - $this->b), '<
case '*' :
echo $this->a, ' * ', $this->b, ' = ', ($this->a * $this->b), '<
case '/' :
if($this->b == 0) {
echo 'You can not divide by zero!<
else {
echo $this->a, ' / ', $this->b, ' = ', ($this->a / $this->b), '<
case '%' :
if((int)$this->b == 0) {
echo (int)$this->a, ' % ', (int)$this->b, ' = ', ((int)$this->a % (int)$this->b), '<
?>
<!DOCTYPE html>
<
html
>
head
meta
charset
"utf-8"
/>
title
>New Page</
script
type
"text/javascript"
src
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"
></
</
body
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$
S
new
Symbol((float)$_POST['a'], (float)$_POST['b'], $_POST['symbol']);
$a = $S->getA();
$b = $S->getB();
if($_REQUEST['clear']) {
$a = null;
$b = null;
form
action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
input
"text"
name
"a"
value="<?php echo $a; ?>" />
label
>Enter a value</
"b"
value="<?php echo $b; ?>" />
select
"symbol"
option
value
"+"
>+</
"-"
>-</
"*"
>*</
"/"
>/</
"%"
>%</
>Select an arithmetic symbol + - * / %</
/><
"submit"
"perform"
"Perform"
/>
"clear"
" Clear "
if($_SERVER['REQUEST_METHOD']=='POST' && $_REQUEST['perform'] && !$_REQUEST['clear']) {
$S->Result();
echo null;
$(document).ready(function() {
$("select").css({"width": "141px", "text-align": "center"});
$("input").css({"text-align": "center"});
});