I have class Router which has array of routes property
<?php
class Router
{
private $routes = [];
function setRoutes(array $routes)
{
$this->$routes = $routes;
}
}
?>
In other File routes.php :
<?php
$routes = [
'users' => 'users.php',
'comments' => 'comments.php'
];
?>
And I use it like :
<?php
require __DIR__ .'/Data.php';
require __DIR__ .'/Router.php';
require __DIR__ .'/../routes.php';
$router = new Router;
$router->setRoutes($routes);
$url = $_SERVER['REQUEST_URI'];
?>
But I'm getting
Notice: Array to string conversion in /../XAMPP/xamppfiles/htdocs/TestPro/core/Router.php
Why this error is occurring ?
Routerclass? Can you give us the content of the line of code withinRouter.phpthat creates the notice?