PHP : travaux pratique 2

Par player cent, il y a 4 ans


aidez moi je ne suis plus le cours

Ce que je veux

voici mon code: <?php require '../vendor/autoload.php'; $router = new AltoRouter(); //On créé une constante pour ne pas se repeter. define('VIEW_PATH', dirname(DIR) . '/views'); $router->map('GET', '/blog', function (){ require VIEW_PATH . '/post/index.php'; }); $router->map('GET', '/blog/category', function (){ require VIEW_PATH . '/category/show.php'; }); $match = $router->match(); $match['target'](); Ce que j'obtiens Warning: Trying to access array offset on value of type bool in C:\Users\lenovo PC\programs\public\index.php on line 17 Fatal error: Uncaught Error: Value of type null is not callable in C:\Users\lenovo PC\programs\public\index.php:17 Stack trace: #0 {main} thrown in C:\Users\lenovo PC\programs\public\index.php on line 17

3 réponses

Carouge10, il y a 4 ans

qu'elle est ton url ?
que vaut $match (à l'aide de la fonction var_dump) ?
si ta route n'est pas inscrite, il faudrait avoir ce cas là comme code, en testant $match par exemple

player cent, il y a 4 ans

merci c'est trouvé dans l'url

Carouge10, il y a 4 ans

super, passe ton sujet en résolu