Anonymous Anonymous - 6 days ago
85 0

No description

PHP

index.php

<?php

class Task {
  public $description;
  public $completed = false;

  public function __construct($description)
  {
    $this->description = $description;
  }

  public function complete()
  {
    $this->$completed = true;
  }

  public function isComplete()
  {
    return $this->$completed;
  }
}

$tasks = [
  new Task("Go to the store"),
  new Task("Finish my screencast"),
  new Task("Finish PHP Course")
];

$tasks[0] -> complete();

require 'index.view.php';
PHP

index.view.php

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Document</title>
  </head>
  <body>
    <ul>

        <?php foreach ($tasks as $task) : ?>

        <li>

            <?php if ($task->completed) : ?>
              <del><?= $task->description; ?></del>
            <?php else: ?>
              <?= $task->description; ?>
            <?php endif; ?>

        </li>

        <?php endforeach; ?>

    </ul>
  </body>
</html>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download