⊗ppMVDFmRrU 26 of 35 menu

Using a Router in Your Own MVC Framework

Let's recall the current contents of the file index.php:

<?php namespace Core; error_reporting(E_ALL); ini_set('display_errors', 'on'); spl_autoload_register(function($class) { // your autoload implementation }); $routes = require $_SERVER['DOCUMENT_ROOT'] . '/project/config/routes.php'; ?>

Now, let's say we want to use our router further in index.php in the following way:

<?php $router = new Router(); $track = $router->getTrack($routes, $_SERVER['REQUEST_URI']); ?>

It can be rewritten more compactly:

<?php $track = ( new Router ) -> getTrack($routes, $_SERVER['REQUEST_URI']); ?>
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline