免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1209 | 回复: 2
打印 上一主题 下一主题

求助!类的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-16 17:43 |只看该作者 |倒序浏览
<?php
class tree{
        var $test = array();

        function into($values){
                $this -> test[] = $values;
        }

        function getcount(){
                return count($test);
        }       
}

$tt = new tree();
$tt -> into('111');
$tt -> into('222');
$tt -> into('333');
echo $tt -> getcount();
?>


为什么显示的是 0 ???
另:怎么在类里向数组里插入新数据

论坛徽章:
0
2 [报告]
发表于 2006-01-16 18:03 |只看该作者
原帖由 梦中的天堂 于 2006-1-16 17:43 发表
<?php
class tree{
        var $test = array();

        function into($values){
                $this -> test[] = $values;
        }

        function getcount(){
                return count($test);
        }       
}

$tt = new tree();
$tt -> ...


  1. <?php
  2. class tree{
  3.         var $test = array();

  4.         function into($values){
  5.                 $this -> test[] = $values;
  6.         }

  7.         function getcount(){
  8.                 return count($this->test);
  9.         }        
  10. }

  11. $tt = new tree();
  12. $tt -> into('111');
  13. $tt -> into('222');
  14. $tt -> into('333');
  15. echo $tt -> getcount();
  16. ?>
复制代码

论坛徽章:
0
3 [报告]
发表于 2006-01-17 10:16 |只看该作者
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP