An entire complex web site or application can be written with a bunch
of ‘insert’s. The design of class.layout comes from the fact that
most of the HTML tags are in pairs and like a container with lots
of attributes. Look here:
of ‘insert’s. The design of class.layout comes from the fact that
most of the HTML tags are in pairs and like a container with lots
of attributes. Look here:
<A HREF="/index.html">Homepage</A>
<A> and </A> is a pair and ‘HREF=”/index.html”‘ are the attributes
of the tag <A>. A simple Anchor object would be:
of the tag <A>. A simple Anchor object would be:
<?php
class Anchor {
var $source = "";
var $attributes = array();
function Anchor ($s,$a) {
$this->source = $s;
$this->attributes = $a;
}
function
printit() {
echo "<A ";
while(list($key,$val) = each($this->attributes)) {
echo "$key ="$val" ";
}
echo ">";
echo $this->source ; echo "</A>";
}
}
?>
Now you can create the:
<A HREF="/index.html">Homepage</A>
with the following code lines:
<?php
$a = new Anchor("/index.html",array("href" => "Homepage"));
$a->printit;
?>