Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I keep getting this error when i include set_width funtion "
Fatal error: Call to a member function set_width() on a non-object in C:\xampplite\htdocs\oop.php on line 48"
any suggestions on what might be the problem?Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
class myHappyBox{
var $box_height = 30;
var $box_width = 100;
var $box_color = '#EC0000';
function myHappyBox(){
}
function set_Height($value){
$this->box_height=$value;
}
function set_width($value){
$this->box_width=$value;
}
function set_Color($value){
$this->box_color=$value;
}
function displayBox(){
echo sprintf('<div style="height:%spx;width:%spx;background-color:%s"> </div>',
$this->box_height,$this->box_width,$this->box_color);
}
}
?>
<?php
$newBox=new myHappyBox();
$newBox->set_Height(100);
$newbox->set_width(100);
$newBox->displayBox();
?>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]