dqd82461 2015-04-01 10:57 采纳率: 0%
浏览 62

如何回应功能之外的东西?

In the following code I want to echo green outside of public function.

Public function lol(){
$green ="green";
}

for example i want to echo $green in the following code.

public function green(){
echo"this is $green";
}
  • 写回答

4条回答 默认 最新

  • douya7121 2015-04-01 11:03
    关注

    You pass $green in as a parameter and echo the function return value:

    function green($green) {
      return "This is ". $green;
    }
    
    echo green('green'); //Results in: This is green
    echo green('yellow'); //Results in: This is yellow
    
    评论

报告相同问题?