PHP Classes

File: examples/example5.php

Recommend this page to a friend!
  Classes of naholyr   First Order Logic Prop   examples/example5.php   Download  
File: examples/example5.php
Role: Example script
Content type: text/plain
Description: Shows how you can extend the base class to have nice HTML output of the values table
Class: First Order Logic Prop
Manipulate, analyze, and prove logic propositions
Author: By
Last change:
Date: 20 years ago
Size: 1,215 bytes
 

Contents

Class file image Download
<?php

require '../FirstOrderLogicProp.inc.php';

class
FOLP_HTML extends FirstOrderLogicProp
{
    function
FOLP_HTML ($formula=NULL,$expand=FALSE) { parent::FirstOrderLogicProp($formula,$expand); }
    function
printValuesTable ($border=1, $attrs='')
    {
       
$formula = parent::toString();
       
$table = parent::valuesTable();
       
$vars = $table['vars'];
       
$vals = $table['values'];
        echo
'<table border="'.$border.'" '.$attrs.'>';
        echo
'<tr>';
        foreach (
$vars as $var) echo '<td align="center"><b style="color:darkblue">'.htmlentities($var).'</b></td>';
        echo
'<td align="center"><b style="color:darkred">'.htmlentities($formula).'</b></td></tr>';
        foreach (
$vals as $v) {
            echo
'<tr>';
            foreach (
$vars as $var) echo '<td align="center"><span style="color:darkblue">'.htmlentities($v['values'][$var]).'</span></td>';
            echo
'<td align="center"><b style="color:darkred">'.$v['result'].'</b></td></tr>';
        }
        echo
'</table>';
    }
}


$formula = isset($_POST['formula']) ? $_POST['formula'] : '(a <!> c) & (b -> c)';
$p = new FOLP_HTML($formula);
$p->addSyntaxFile('syntax.litteral');
$p->printValuesTable();


?>