예제 #1
0
        // Empty first header cell.
        foreach ($this->backgroundColor as $col) {
            echo "<th> {$col} <br /> color </th>";
        }
        echo "</tr>";
        // Third, set the rows.
        foreach ($this->textColor as $row) {
            echo "<tr>";
            echo "<th> {$row} <br /> text </th>";
            for ($i = 0; $i < count($this->backgroundColor); $i++) {
                echo "<td style=\"color:{$row}\"> {$row} </td>";
            }
            echo "</tr>";
        }
        echo "</table>";
    }
}
if (isset($_GET['submit'])) {
    if (empty($_GET['backgroundColor']) || empty($_GET['textColor'])) {
        echo "Error: You have not selected a text or background color. Please reselect.";
    } else {
        $newColor = new colorChanger($_GET['backgroundColor'], $_GET['textColor']);
        $newColor->changeColor();
    }
} else {
    $defaultForm = new formCreater();
    echo $defaultForm->content();
}
?>
</body>
</html>
예제 #2
0
    }
    public function getColor()
    {
        $this->setColor();
    }
    public function getForm()
    {
        $this->getContent();
    }
}
if (isset($_GET['submit'])) {
    if (empty($_GET['backgroundColor']) || empty($_GET['textColor'])) {
        echo "Error: You have not selected a text or background color. <br />\n                  Please reselect with the form below, created using an extended Class object calling a protected method:";
        $reselect = new reselectionForm();
        $reselect->getReselectionForm();
    } else {
        $newColor = new colorChanger($_GET['backgroundColor'], $_GET['textColor']);
        echo "Begin by trying to access the color changer directly via public method getColor().<br />";
        $newColor->getColor();
        echo "Success! Let's try to access private method setColor() this time! Should output an error message:<br />";
        if ($newColor->setColor()) {
            echo "...Success?<br />";
        }
    }
} else {
    $defaultForm = new formCreater();
    echo $defaultForm->getInitialContent();
}
?>
</body>
</html>