类的成员变量问题?急等!!

wangguan007 2005-12-16 06:11:33
从网上下载了个类文件,使用后没问题。在原来的类文件的基础上,添加了一个成员变量,
相应的把构造函数也修改了,怎么看都应该没问题,可是报这样的信息

Warning: Missing argument 10 for treenode() in d:\workspace\sgw1.0\bbs\treenode_class.php on line 21

原来的构造函数有9个变量,增加一个后提示第十个变量丢了,
构造函数就是在第21行

我的是 PHP4.4,各位高手多多指教啊,在线急等!!
...全文
265 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
helloyou0 2005-12-18
  • 打赏
  • 举报
回复
不是这边,要找你new的地方,只提供了9个参数。
或者这边加上default值
wangguan007 2005-12-17
  • 打赏
  • 举报
回复
不是 oo 也没关系,只要类文件能顺利编译就行了

现在的问题如上所述

麻烦高手帮忙看看。
-神仙- 2005-12-16
  • 打赏
  • 举报
回复
看了这个程序,感觉不是oo的
不是用了class就是oo
看你一个函数那么多参数就感觉不对
lostgdi731 2005-12-16
  • 打赏
  • 举报
回复
对OO 厌倦了,
写到后边还是向效率靠拢。
wangguan007 2005-12-16
  • 打赏
  • 举报
回复
麻烦唠叨帮忙看看,谢谢!!
wangguan007 2005-12-16
  • 打赏
  • 举报
回复
我添加一个字段后的类文件 , 添加的字段是 var $m_parent_topic_id;

<?php
// functions for loading, contructing and
// displaying the tree are in this file

class treenode
{
// each node in the tree has member variables containing
// all the data for a post except the body of the message
var $m_topic_id;
var $m_parent_topic_id;
var $m_topic_title;
var $m_creater_id;
var $m_create_time;
var $m_children;
var $m_childlist;
var $m_depth;

//function __construct($postid, $title, $poster, $posted, $children,
function treenode($topic_id, $parent_topic_id, $topic_title, $creater_id, $create_time, $children,
$expand, $depth, $expanded, $sublist)
{
// the constructor sets up the member variables, but more
// importantly recursively creates lower parts of the tree
$this->m_topic_id = $topic_id;
$this->m_parent_topic_id = $parent_topic_id;
$this->m_topic_title = $topic_title;
$this->m_creater_id = $creater_id;
$this->m_create_time = $create_time;
$this->m_children =$children;
$this->m_childlist = array();
$this->m_depth = $depth;

// we only care what is below this node if it
// has children and is marked to be expanded
// sublists are always expanded
if(($sublist||$expand) && $children)
{
$conn = db_connect();

$query = "select * from tbbs_topics where parent_topic_id = $topic_id";
//echo "<br>$query";
$result = pg_query($conn, $query);

for ($count=0; $row = pg_fetch_assoc($result); $count++)
{
if($sublist||$expanded[ $row['topic_id'] ] == true)
$expand = true;
else
$expand = false;
$this->m_childlist[$count]= new treenode($row['topic_id'],$row['parent_topic_id'],
$row['topic_title'],
$row['creater_id'],$row['create_time'],
$row['children'], $expand,
$depth+1, $expanded, $sublist);
}
}
}


function display($row, $sublist = false)
{
// as this is an object, it is responsible for displaying itself

// $row tells us what row of the display we are up to
// so we know what color it should be

// $sublist tells us whether we are on the main page
// or the message page. Message pages should have
// $sublist = true.
// On a sublist, all messages are expanded and there are
// no "+" or "-" symbols.

// if this is the empty root node skip displaying
if($this->m_depth>-1)
{
//echo "hahaha";
//color alternate rows
echo'<table width="560" height="20" border="0" cellpadding="0" cellspacing="0">';
echo '<tr><td align="left" valign="middle" bgcolor = ';
if ($row%2)
echo "'#e5e5e5'>";
else
echo "'#ffffff'>";

// indent replies to the depth of nesting
for($i = 0; $i<$this->m_depth; $i++)
{
echo "<img src=\"/e/e_common/e_res_sankaku.gif\" width=\"25\" height=\"20\">";
}

// display + or - or a spacer
if ( !$sublist && $this->m_children && sizeof($this->m_childlist))
// we're on the main page, have some children, and they're expanded
{
// we are expanded - offer button to collapse
echo "<a href = 'index.php?collapse=".
$this->m_topic_id."#$this->m_topic_id'
><img src = '/e/e_common/e_res_sankaku.gif' valign = 'bottom'
height = 22 width = 22 alt = 'Collapse Thread' border = 0 /></a>";
}
else if(!$sublist && $this->m_children)
{
// we are collapsed - offer button to expand
echo "<a href = 'index.php?expand=".
$this->m_topic_id."#$this->m_topic_id'><img src = '/e/e_common/e_res_sankaku.gif'
height = 22 width = 22 alt = '' border = 0></a>";
}
else
{
// we have no children, or are in a sublist, do not give button
echo "<img src = 'images/spacer.gif' height = 20 width = 20
alt = '' valign = 'center' />";
}


echo " <a name = $this->m_topic_id ><a href =
'view_post.php?topic_id=$this->m_topic_id'>$this->m_topic_title -
$this->m_creater_id - ".reformat_date($this->m_create_time).'</a>';
echo '</td></tr>';

// increment row counter to alternate colors
$row++;
}
// call display on each of this node's children
// note a node will only have children in its list if expanded
$num_children = sizeof($this->m_childlist);
for($i = 0; $i<$num_children; $i++)
{
$row = $this->m_childlist[$i]->display($row, $sublist);
}
return $row;
}
};

?>
wangguan007 2005-12-16
  • 打赏
  • 举报
回复
原来的类文件:
<?php
// functions for loading, contructing and
// displaying the tree are in this file

class treenode
{
// each node in the tree has member variables containing
// all the data for a post except the body of the message
var $m_topic_id;
var $m_topic_title;
var $m_creater_id;
var $m_create_time;
var $m_children;
var $m_childlist;
var $m_depth;

//function __construct($postid, $title, $poster, $posted, $children,
function treenode($topic_id, $topic_title, $creater_id, $create_time, $children,
$expand, $depth, $expanded, $sublist)
{
// the constructor sets up the member variables, but more
// importantly recursively creates lower parts of the tree
$this->m_topic_id = $topic_id;
$this->m_topic_title = $topic_title;
$this->m_creater_id = $creater_id;
$this->m_create_time = $create_time;
$this->m_children =$children;
$this->m_childlist = array();
$this->m_depth = $depth;

// we only care what is below this node if it
// has children and is marked to be expanded
// sublists are always expanded
if(($sublist||$expand) && $children)
{
$conn = db_connect();

$query = "select * from tbbs_topics where parent_topic_id = $topic_id";
//echo "<br>$query";
$result = pg_query($conn, $query);

for ($count=0; $row = pg_fetch_assoc($result); $count++)
{
if($sublist||$expanded[ $row['topic_id'] ] == true)
$expand = true;
else
$expand = false;
$this->m_childlist[$count]= new treenode($row['topic_id'],$row['topic_title'],
$row['creater_id'],$row['create_time'],
$row['children'], $expand,
$depth+1, $expanded, $sublist);
}
}
}


function display($row, $sublist = false)
{
// as this is an object, it is responsible for displaying itself

// $row tells us what row of the display we are up to
// so we know what color it should be

// $sublist tells us whether we are on the main page
// or the message page. Message pages should have
// $sublist = true.
// On a sublist, all messages are expanded and there are
// no "+" or "-" symbols.

// if this is the empty root node skip displaying
if($this->m_depth>-1)
{
//echo "hahaha";
//color alternate rows
echo'<table width="560" height="20" border="0" cellpadding="0" cellspacing="0">';
echo '<tr><td align="left" valign="middle" bgcolor = ';
if ($row%2)
echo "'#e5e5e5'>";
else
echo "'#ffffff'>";

// indent replies to the depth of nesting
for($i = 0; $i<$this->m_depth; $i++)
{
echo "<img src=\"/e/e_common/e_res_sankaku.gif\" width=\"25\" height=\"20\">";
}

// display + or - or a spacer
if ( !$sublist && $this->m_children && sizeof($this->m_childlist))
// we're on the main page, have some children, and they're expanded
{
// we are expanded - offer button to collapse
echo "<a href = 'index.php?collapse=".
$this->m_topic_id."#$this->m_topic_id'
><img src = '/e/e_common/e_res_sankaku.gif' valign = 'bottom'
height = 22 width = 22 alt = 'Collapse Thread' border = 0 /></a>";
}
else if(!$sublist && $this->m_children)
{
// we are collapsed - offer button to expand
echo "<a href = 'index.php?expand=".
$this->m_topic_id."#$this->m_topic_id'><img src = '/e/e_common/e_res_sankaku.gif'
height = 22 width = 22 alt = '' border = 0></a>";
}
else
{
// we have no children, or are in a sublist, do not give button
echo "<img src = 'images/spacer.gif' height = 20 width = 20
alt = '' valign = 'center' />";
}


echo " <a name = $this->m_topic_id ><a href =
'view_post.php?topic_id=$this->m_topic_id'>$this->m_topic_title -
$this->m_creater_id - ".reformat_date($this->m_create_time).'</a>';
echo '</td></tr>';

// increment row counter to alternate colors
$row++;
}
// call display on each of this node's children
// note a node will only have children in its list if expanded
$num_children = sizeof($this->m_childlist);
for($i = 0; $i<$num_children; $i++)
{
$row = $this->m_childlist[$i]->display($row, $sublist);
}
return $row;
}
};

?>
xuzuning 2005-12-16
  • 打赏
  • 举报
回复
是“增加一个后提示第十个变量丢了”吗?
是说有10个参数,而你只提供了9个!

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧