class struct {
public $variable=$_SESSION['Example'];
}
Run Code Online (Sandbox Code Playgroud)
如何调用Session并将其放入php类的变量中?
阅读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)