Hello,
So writing html in php is ugly and error prone. Every opening and closing tag is an opportunity for a typo. It is also quite hard to read the code, upsets indentation (you have the indentation of the html and the indentation of the php code to maintain!), and it can lead to loads of wasted whitepace characters in the html.
I want to use, or make a library that allows me to get around that problem. If I write a table, I want it to be as simple as:
Some helper functions/classes
// prepares an input array for functions and classes
class PrepareInput {
private $inputs = array();
// adds an input value to the array
public function input($name=null, $value=null) {
if (!is_null($name) && !is_null($value)) {
$this->inputs[$name] = $value;
}
}
// outputs the array and clears it ready for another preparation array to be built
public function output() {
$out = $this->in;
$this->inputs = array();
return $out;
}
}
// prepare input shortcut
function p($prepareInputObject, $name, $value) {
$prepareInputObject->input($name, $value);
}
function pOut($prepareInputObject) {
return $prepareInputObject->output();
}
$p = new PrepareInput;
Implementation:
p($p, 'colTitle', ['Visitor Name', 'Arrival Time', 'Departure Time']);
p($p, 'rows',
[
['Bob', '9am', ['10pm', 'class', 'lateFinish']],
['Jill', '9:40am', '11am'],
['Jack', '1pm', '2pm']
]
);
$table = new HTMLTable(pOut());
p('rowNum', 0);
p('attribute', ['class', 'morningVisit']);
$table.addRowAttrubute(pOut());
$htmlPage.add($table);
$htmlPage.printPage();
I haven’t been able to find a library that, is there one I have missed? Or do I have to write one?
Thanks
RT_