-4

我刚开始使用类,但是当我执行包含该类的页面时,我的脚本就停止了。另外,代码和功能本身并不完整,只是在一些基础上添加了一些代码。

class doVersus
{
        private var $p1health;
        private var $p2health;
        private var $dmg;
        public var $longlog;
        function __construct($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n)
        {

                if($stg==0)
                {
                        $longlog = "The battle has begun..<br>".$_GET['user'];
                        //startBattle($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n);
                        echo $longlog;
                }else{
                        $longlog = $longlog."TURN: ".$stg."<br>";
                        //startBattle($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n);
                        echo $longLog;

        }

        private function startBattle($hp1m, $hp1c, $hp2m, $hp2c, $stg, $prev_log, $hp2n)
        {
                if($hp1c<0 || $hp2c<0)
                {
                        $longlog = $longlog."The battle has ended!<br>"
                        stopBattle($hp1c, $hp2c);
                }else{
                        echo $longlog;
                }
        }
        private function doDmg($a)
        {
                $longlog = $longlog." strikes ".$hp2n." with ".$dmg." normal damage";
        }
        private function stopBattle($a, $b)
        {
                echo $longlog." Battle has ended.";
        }
}
4

3 回答 3

3

}最后,您的构造函数 ( __construct)中缺少A。

于 2012-09-15T10:38:28.563 回答
1

You didn't closed the else statement in the constructor.

Then, in PHP5, you don't need to declare variables by writing var in your declarations.

于 2012-09-15T10:49:44.417 回答
1

看起来else构造函数没有关闭

于 2012-09-15T10:40:16.940 回答