2014-10-17 50 views
0

当我使用下面的代码,我得到这个错误:在类:调用函数与函数

Fatal error: Call to undefined function passwordHash() in 
C:\(...)\index.php on line 38 

如果我做的东西$ =新accountcreation;

并通过$ somethingn-> passwordHash()调用它,我可以调用该函数。

但是,如何从课堂内部以我想要的方式调用函数? (见函数:callMethods();)

谢谢。

class accountcreation { 

    function __construct($passwordCreation, $userCreation, 
       $ipCreation, $emailCreation, $con) { 
     $this->passwordCreation = $passwordCreation; 
     $this->userCreation = $userCreation; 
     $this->ipCreation = $ipCreation; 
     $this->emailCreation = $emailCreation; 
     $this->con = $con; 

    } 

    function callMethods() { 
     passwordHash(); 
    } 

    function passwordHash(){ 
     $this->passwordCreation = 
       password_hash($this->passwordCreation, PASSWORD_BCRYPT); 
     var_dump($this->passwordCreation); 
    } 
} 

回答

2

$this->passwordHash()怎么样? :)与C++相比,您总是必须明确指定this/$this

+0

那么,这是无痛的....谢谢。 – icor103 2014-10-17 08:54:34