Assigning a function's result to a variable within a PHP class? OOP Weirdness

前端 未结 3 1203
悲哀的现实
悲哀的现实 2020-12-06 20:43

I know you can assign a function\'s return value to a variable and use it, like this:

function standardModel()
{
    return \"Higgs Boson\";   
}

$nextBigTh         


        
3条回答
  •  一生所求
    2020-12-06 20:48

    class standardModel
    {
    // Public instead of private
    public function nextBigThing()
    {
        return "Higgs Boson";   
    }
    }
    
    $standardModel = new standardModel(); // corection
    
    echo $standardModel->nextBigThing(); 
    

提交回复
热议问题