English 中文(简体)
目标功能在公共卫生和公共卫生部赢得执行
原标题:Object function won t execute in PHP

I m 运行Eclipse Indigo, with PDT and Xdebugger (all recent edition) and a LAMP服务器 on Hugo 11.04.

物体功能(见下面的代码)在分解时赢得了拖拉;变相的只是违约——变数窗口完全空白,只是冻结。 该网页既能赢得装货,也只能停留在装货国。

一切都罚款,直到我开始在物体上任职。

建议

该法典:

 <?php 
    require_once  user.php ;
    require_once  fetcher.php ;
    require_once  inscriber.php ;
    $uname=$_POST[ regname ];
    $upass=$_POST[ regpass ];
    $ufirst=$_POST[ regfirst ];
    $ulast=$_POST[ reglast ];
    $uemail=$_POST[ regemail ];
    $uphone=$_POST[ regphone ];

    $user = new User();
    $user->setUsername($uname); // THIS IS WHERE IT FREEZES UP
    $user->setPassword($upass);
    $user->setFirstname($ufirst);
    $user->setLastname($ulast);
    $user->setEmail($uemail);
    $user->setPhone($uphone);

    $inscriber = Inscriber::getInscriberInstance();
    $success = $inscriber->inscribeUser($user);
    ?>




<?php
class User{

    private $username;
    private $password;
    private $userID;
    private $firstname;
    private $lastname;
    private $phone;
    private $email;


    public function getUsername(){
        return $username;
    }

    public function setUsername($var){
        $this->$username = $var;
    }
    ///

    public function getPassword(){
        return $password;
    }

    public function setPassword($var){
        $this->$password = $var;
    }
    ///

    public function getUserID(){
        return $userID;
    }

    public function setUserID($var){
        $this->$userID = $var;
    }
    ///

    public function getFirstname(){
        return $firstname;
    }

    public function setFirstname($var){
        $this->$firstname = $var;
    }
    ///

    public function getLastname(){
        return $lastname;
    }

    public function setLastname($var){
        $this->$lastname = $var;
    }
    ///

    public function getPhone(){
        return $phone;
    }

    public function setPhone($var){
        $this->$phone = $var;
    }
    ///

    public function getEmail(){
        return $email;
    }

    public function setEmail($var){
        $this->$email = $var;
    }


}
最佳回答
$this->$username = $var;

这是“不动产”。 PHP试图用变量的内容取代$username。 变量为t,因此产生的<代码>$this-> = var 公正的失败

$this->username = $var;

(非静态)特性始终没有<条码><$>/code>。

你们正在使用当地变量的接收器中的附加物

public function getUsername(){
    return $username;
}

不知道,为什么你(至少试图)在固定装置中使用财产,但在接收器中使用当地变量

public function getUsername(){
    return $this->username;
}

脚注:“目标功能”称为“方法”。

问题回答

你的辛子并不正确(在这种情况下)。 请:

//...

public function getUsername(){
  return $this->username; //added $this->...
}

public function setUsername($var){
  $this->username = $var; //no $-sign before  username 
}


//...

This goes for all the other functions, too.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签