I'd like to create some classes in a loop, I give the name of the class in a variable.
I get an error:
Fatal error: Uncaught Error: Class name must be a valid object or a string in ...
How can I do this?
<?php
$xml = simplexml_load_file('routes.xml');
$routes = $xml->Route;
for($i =0; $i<count($routes); $i++){
$uri = $routes[$i]->attributes()->uri;
$name = $routes[$i]->attributes()->name;
Route::set($uri, function(){
$name::CreateView();
});
}
?>
File XML
<?xml version="1.0" encoding="utf-8" ?>
<Routes>
<Route name="Home" uri="" controller="Home"/>
<Route name="AboutMe" uri="o-mnie" controller="AboutMe"/>
<Route name="Interests" uri="o-mnie/zainteresowania" controller="AboutMe" method="interests"/>
<Route name="Contact" uri="kontakt" controller="Contact"/>
</Routes>