Тег <label></label>




Этот тег определяет метку для элемента.



Аргумент Значение
for element_id
form form_id




index.php
  • <?php
  • class Symbol {
  •  private $a = null;
  •  private $b = null;
  •  private $symbol = null;
  •  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), '<br />';
  •    break;
  •    case '*' :
  •     echo $this->a, ' * ', $this->b, ' = ', ($this->a * $this->b), '<br />';
  •    break;
  •    case '/' :
  •     if($this->b == 0) {
  •      echo 'You can not divide by zero!<br />';
  •     }
  •     else {
  •      echo $this->a, ' / ', $this->b, ' = ', ($this->a / $this->b), '<br />';
  •     }
  •    break;
  •    case '%' :
  •     if((int)$this->b == 0) {
  •      echo 'You can not divide by zero!<br />';
  •     }
  •     else {
  •      echo (int)$this->a, ' % ', (int)$this->b, ' = ', ((int)$this->a % (int)$this->b), '<br />';
  •     }
  •    break;
  •   }
  •  }
  • }
  • ?>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  • <?php
  • 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 type="text" name="a" value="<?php echo $a; ?>" />
  •  &nbsp;
  •  <label>Enter a value</label>
  •  <br />
  •  <br />
  •  <input type="text" name="b" value="<?php echo $b; ?>" />
  •  &nbsp;
  •  <label>Enter a value</label>
  •  <br />
  •  <br />
  •  <select name="symbol">
  •   <option value="+">+</option>
  •   <option value="-">-</option>
  •   <option value="*">*</option>
  •   <option value="/">/</option>
  •   <option value="%">%</option>
  •  </select>
  •  &nbsp;
  •  <label>Select an arithmetic symbol + - * / %</label>
  •  <br /><br /><br /><br /><br /><br />
  •  <input type="submit" name="perform" value="Perform" />&nbsp;
  •  &nbsp;&nbsp;
  •  <input type="submit" name="clear" value="&nbsp;&nbsp;&nbsp;Clear&nbsp;&nbsp;&nbsp;" />
  •  <br />
  •  <br />
  • </form>
  • <?php
  • if($_SERVER['REQUEST_METHOD']=='POST' && $_REQUEST['perform'] && !$_REQUEST['clear']) {
  •  $S->Result();
  • }
  • else {
  •  echo null;
  • }
  • ?>
  • <script>
  •  $(document).ready(function() {
  •   $("select").css({"width": "141px", "text-align": "center"});
  •   $("input").css({"text-align": "center"});
  •  });
  • </script>
  • </body>
  • </html>
  • <?php
  • class Symbol {
  •  private $a = null;
  •  private $b = null;
  •  private $symbol = null;
  •  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), '<br />';
  •    break;
  •    case '*' :
  •     echo $this->a, ' * ', $this->b, ' = ', ($this->a * $this->b), '<br />';
  •    break;
  •    case '/' :
  •     if($this->b == 0) {
  •      echo 'You can not divide by zero!<br />';
  •     }
  •     else {
  •      echo $this->a, ' / ', $this->b, ' = ', ($this->a / $this->b), '<br />';
  •     }
  •    break;
  •    case '%' :
  •     if((int)$this->b == 0) {
  •      echo 'You can not divide by zero!<br />';
  •     }
  •     else {
  •      echo (int)$this->a, ' % ', (int)$this->b, ' = ', ((int)$this->a % (int)$this->b), '<br />';
  •     }
  •    break;
  •   }
  •  }
  • }
  • ?>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  • <?php
  • 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 type="text" name="a" value="<?php echo $a; ?>" />
  •  &nbsp;
  •  <label>Enter a value</label>
  •  <br />
  •  <br />
  •  <input type="text" name="b" value="<?php echo $b; ?>" />
  •  &nbsp;
  •  <label>Enter a value</label>
  •  <br />
  •  <br />
  •  <select name="symbol">
  •   <option value="+">+</option>
  •   <option value="-">-</option>
  •   <option value="*">*</option>
  •   <option value="/">/</option>
  •   <option value="%">%</option>
  •  </select>
  •  &nbsp;
  •  <label>Select an arithmetic symbol + - * / %</label>
  •  <br /><br /><br /><br /><br /><br />
  •  <input type="submit" name="perform" value="Perform" />&nbsp;
  •  &nbsp;&nbsp;
  •  <input type="submit" name="clear" value="&nbsp;&nbsp;&nbsp;Clear&nbsp;&nbsp;&nbsp;" />
  •  <br />
  •  <br />
  • </form>
  • <?php
  • if($_SERVER['REQUEST_METHOD']=='POST' && $_REQUEST['perform'] && !$_REQUEST['clear']) {
  •  $S->Result();
  • }
  • else {
  •  echo null;
  • }
  • ?>
  • <script>
  •  $(document).ready(function() {
  •   $("select").css({"width": "141px", "text-align": "center"});
  •   $("input").css({"text-align": "center"});
  •  });
  • </script>
  • </body>
  • </html>