Hi,
Please i wondered if anyone out there could
just pity my life in php and do the correction for me??
I am just trying to get my kindergarten of php into
understanding of how to use an html_class in php.
Please do.
Thanks
Mo jam
[ php]
<?php
class Style {
var $text;
var $alink;
var $vlink;
var $link;
var $bgcol;
var $face;
var $size;
var $align;
var $valign;
}
function Style ($text="#CCCCFF",$alink="#AA00AA",
$vlink="#AA00AA",$link="#3333FF",
$bgcol="#999999",$face="Book Antiqua",$size=3,$align="CENTER",$valign="TOP") {
$this->text=$text;
$this->alink=$alink;
$this->vlink=$vlink;
$this->link=$link;
$this->bgcol=$bgcol;
$this->face=$face;
$this->size=$size;
$this->align=$align;
$this->valign=$valign;
}
}
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";
}
function TextOut($message=" ") {
PRINT "<FONT FACE=\"$this->face\" ".
"SIZE=$this->size COLOR=\"$this-> ".
"text\">$message</FONT>\n";
}
?>
[ /php]
HTML Classes
Moderator: General Moderators
use indents and you will see that some curly brackets are at the wrong place. If your project gets more complex comments get quite handy.
if I get stucked in a project I review my comments or (if not already done) I start to comment at least the part that seems to cause errors. I found this very useful in finding bugs
Code: Select all
<?php
class example
{
/** myVar: if no comment for something comes to your mind, maybe
it is useless
*/
var myVar;
/** constructor for class example
sets all member var.s to valid defaults
*/
function example()
{
myVar = 0;
// ...
} // end of function example
/** calculates the square of member myVar
@returns Integer, myVar*myVar
*/
function square()
{
return (int)myVar*(int)myVar;
} // end of function square
...
} // end of class example
?>HTML_Class
Hi,
Please can anyone still explain why i get an error at the last line where i declared the function??
I need help.
<?php
class Style
{
var $text;
var $alink;
var $vlink;
var $link;
var $bgcol;
var $face;
var $size;
var $align;
var $valign;
// you closed off the class at this bracket,
//there for you prolly got a error saying "call to a undefined object or something"
// }
function Style( $text="#CCCCFF", $alink="#AA00AA", $vlink="#AA00AA", $link="#3333FF", $bgcol="#999999",$face="Book Antiqua", $size=3,$align="CENTER",$valign="TOP")
{
$this->text=$text;
$this->alink=$alink;
$this->vlink=$vlink;
$this->link=$link;
$this->bgcol=$bgcol;
$this->face=$face;
$this->size=$size;
$this->align=$align;
$this->valign=$valign;
}
// did it again
// }
function Body()
{
// just use echo im not looking through this, im just showing you the proper structure for the class
echo "<BODY BGCOLOR=\"$this->bgcol\" ".
"TEXT=\"$this->text\" ".
"LINK=\"$this->link\" VLINK=\"$this->vlink\" ".
"ALINK=\"$this->alink\"><FONT ".
"FACE=\"$this->face\" SIZE=$this->size>\n";
}
function TextOut($message=" ")
{
echo "<FONT FACE=\"$this->face\" ".
"SIZE=$this->size COLOR=\"$this-> ".
"text\">$message</FONT>\n";
}
}
// we close off the class, now we have to activate it.
$style_class = new Style;
$style_class->function(arguments); // an error here
?>
Please can anyone still explain why i get an error at the last line where i declared the function??
I need help.
<?php
class Style
{
var $text;
var $alink;
var $vlink;
var $link;
var $bgcol;
var $face;
var $size;
var $align;
var $valign;
// you closed off the class at this bracket,
//there for you prolly got a error saying "call to a undefined object or something"
// }
function Style( $text="#CCCCFF", $alink="#AA00AA", $vlink="#AA00AA", $link="#3333FF", $bgcol="#999999",$face="Book Antiqua", $size=3,$align="CENTER",$valign="TOP")
{
$this->text=$text;
$this->alink=$alink;
$this->vlink=$vlink;
$this->link=$link;
$this->bgcol=$bgcol;
$this->face=$face;
$this->size=$size;
$this->align=$align;
$this->valign=$valign;
}
// did it again
// }
function Body()
{
// just use echo im not looking through this, im just showing you the proper structure for the class
echo "<BODY BGCOLOR=\"$this->bgcol\" ".
"TEXT=\"$this->text\" ".
"LINK=\"$this->link\" VLINK=\"$this->vlink\" ".
"ALINK=\"$this->alink\"><FONT ".
"FACE=\"$this->face\" SIZE=$this->size>\n";
}
function TextOut($message=" ")
{
echo "<FONT FACE=\"$this->face\" ".
"SIZE=$this->size COLOR=\"$this-> ".
"text\">$message</FONT>\n";
}
}
// we close off the class, now we have to activate it.
$style_class = new Style;
$style_class->function(arguments); // an error here
?>
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Please stop posting multiple threads about the same problem - from now on just post everything relevant to this here.
http://www.devnetwork.net/forums/viewtopic.php?t=3899
http://www.devnetwork.net/forums/viewtopic.php?t=3925
Mac
http://www.devnetwork.net/forums/viewtopic.php?t=3899
http://www.devnetwork.net/forums/viewtopic.php?t=3925
Mac