I want to use variables in another php file as the class. But I get always the error: Notice: Undefined variable:...
First: I create a user object: File: index.php
<?php
// include the configs / constants for the db connection
require_once("config/config.php");
// load the user class
require_once("classes/User.php");
$user = new User();
include("views/order.php");
File: User.php
class User
{
public $color = "green";
}
File livesearch.php
require_once("../classes/User.php");
echo $User->color;
I create an object from the class user in a index.php file, I use there also a require once to the User.php file and it works. Why I cant access the variable of the class?