Beginning PHP by Unknown
Author:Unknown
Language: eng
Format: mobi, epub
Publisher: Packt Publishing
Now, set up the following variables:$url = explode('/', trim($_SERVER['REQUEST_URI'], '/')); $controller = !empty($url[0]) ? $url[0] : $config['default_controller']; $method = !empty($url[1]) ? $url[1] : $config['default_method']; $args = !empty($url[2]) ? array_slice($url, 2) : array(); $class = $config['namespace'].$controller;0
Note
The $url will hold an array from the requested route in the form of /page/requested. This is how it works: When explode is run, it finds a forward slash in the requested URI, which the $_SERVER makes available.
Next, the $controller method uses a ternary operator to check if the 0 index of $url exists, otherwise the default_controller defined in the Config class is used.
The $method checks for the existence of a $url[1], otherwise it reads from the config class.
$args will get all other indexes of $url after the first 2.
$class holds the path to the controllers as set in the Config class.
What these parameters do is get the Controller, Method, and parameters from the requested URL. For instance:
http://localhost:8000/contacts/view/2
This results in:
Contacts = Contacts class.
View = View method inside the contacts class.
2 = A parameter passed to the method.
If the requested URL is http:://localhost:8000/, then no controller or method is requested, so the default controller and method will be used, as set in system\Config.php.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8298)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6736)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6713)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6588)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6371)
Driving Data Quality with Data Contracts by Andrew Jones(6321)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6086)
Learning SQL by Alan Beaulieu(5994)
Weapons of Math Destruction by Cathy O'Neil(5779)
Big Data Analysis with Python by Ivan Marin(5362)
Data Engineering with dbt by Roberto Zagni(4359)
Solidity Programming Essentials by Ritesh Modi(4008)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3866)
Pandas Cookbook by Theodore Petrou(3577)
Blockchain Basics by Daniel Drescher(3294)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2905)
Feature Store for Machine Learning by Jayanth Kumar M J(2814)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2796)
Mastering Python for Finance by Unknown(2744)
