有没有理由我不能在课堂上宣布公开?

Ste*_*ons 3 php

class struct {
public $variable=$_SESSION['Example'];
}
Run Code Online (Sandbox Code Playgroud)

如何调用Session并将其放入php类的变量中?

Nav*_*eed 6

阅读http://php.net/manual/en/language.oop5.php

class struct {
 public $variable;
 public function __construct(){
   session_start();
   $this->variable = $_SESSION['Example'];
 }
}
Run Code Online (Sandbox Code Playgroud)