classes and php
great, now what to we do with it? im glad you asked. we need to create a few more functions within style to actually accomplish anything. the first thing id like to do is set up my page body so i did this:
<?php
function body() {
print "<body bgcolor=\"$this->bgcol\" ".
"text=\"$this->text\" ".
"link=\"$this->link\" vlink=\"$this->vlink\" ".
"alink=\"$this->alink\"><font ".
"face=\"$this->face\" size=$this->size>\n";
}
?>
this sets up the page body for us. it also illustrates a new variable "$this." when used inside of a class function it lets the interpreter know we are referring to a variable of this instance. in other words, its assigned the value of the name of the instance in the calling line (e.g. $this would be == $basic when $basic->body() is the calling statement.) also, notice we are doing something here thats much simpler than is possible in regular functions. were referring to variables that were not passed to the function. remember, all functions and variables of an instance are available to all functions of that instance. to do this with regular functions youd have to set up several global arrays.
try this in your php script (assuming youve included the style class, created the style objects above and sent the <html> and <head></head> tags):
<?php $basic->body(); ?>
now, were ready to print something out. we could do it the old fashioned way, but im going to do something different… thats right another function:
<?php
function textout($message=" ") {
print "<font face=\"$this->face\" ".
"size=$this->size color=\"$this-> ".
"text\">$message</font>\n";
}
?>