Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- class Example{
- /**
- * Inicialize
- */
- public function __construct()
- {
- if(empty($_SESSION['value']))
- {
- $_SESSION['value'] = 0;
- }
- }
- public function setValue()
- {
- $_SESSION['value']++;
- }
- public function getValue($value='')
- {
- return $_SESSION['value'];
- }
- }
- $example = new Example;
- if(isset($_POST['submit']))
- {
- $example->setValue();
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
- </head>
- <body>
- <div class="container">
- <div class="col-md-4">
- <form action="" method="POST" role="form">
- <legend>Valor: <?php echo $example->getValue(); ?></legend>
- <button name="submit" value="submit" type="submit" class="btn btn-primary">Depositar</button>
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement