class struct { public $variable=$_SESSION['Example']; }
How can I call a session and put it in a variable in php classes?
Read http://php.net/manual/en/language.oop5.php
class struct { public $variable; public function __construct(){ session_start(); $this->variable = $_SESSION['Example']; } }
Properties can only have default literals, not arbitrary expressions. The easiest way to do this:
class Struct { public $variable; public function __construct() { $this->variable = $_SESSION['Example']; } }
You cannot set any properties in a definition unless they are a constant, for example. TRUE, array()etc.
TRUE
array()
In __construct()you can install it.
__construct()
Source: https://habr.com/ru/post/1794344/More articles:Help with iOS app crashing with "Out Of Memory" - c #LINQ Many for many with In or Contause (and a twist) - c #Using RedirectToAction with a Custom Type Parameter - asp.net-mvc-2how to use token in drupal? - drupal-6What is the cause of error 500/503 in Apache / Mono? - apacheHow to import a .tmx file (tile map editor) into my XNA project - c #How to use calendar in iPhone app? - iosВиджет запускает диалог по щелчку - androidCreating a custom button in a ListView in ASP.NET - asp.netMysql retrieves polygonal data - phpAll Articles