click below
click below
Normal Size Small Size show me how
M1 - Web Sys
WEB SYSTEM TECHNOLOGIES / IT0049
| Question | Answer |
|---|---|
| Which line of code correctly defines a route that maps the URL /about to the about() method of the Pages controller? | $routes->get('/about', 'Pages::about'); |
| What is the purpose of a route placeholder such as (:num) in CodeIgniter routing? | It captures a numeric segment of the URL and passes it as a parameter |
| What architectural pattern separates an application into three interconnected components responsible for data, presentation, and control logic? | MVC (Model-View-Controller) |
| A developer argues that since a static PHP array "basically behaves like a small database," there is no real reason to ever migrate a working application to a real database. What is the strongest counterargument? | A static array's data disappears when the server restarts and cannot be reliably shared, searched, or updated by multiple users the way a database can |
| Matching type. Match the term with the correct description. | |
| Route | Maps an incoming URL to a specific controller and method |
| Controller | Decides what should happen when a specific URL is requested |
| Model | Manages data and communicates with the database |
| View | Displays information to the user, usually as HTML |
| What is the term for a segment of a route pattern (such as (:num)) that captures part of the URL and passes it to a controller method as a parameter? | Route placeholder (wildcard) |
| Passing data to a View requires converting the data into a special CodeIgniter-only data type before calling view(). | False |
| Installing CodeIgniter 4 with Composer is the only way to create a new CodeIgniter project. | False |
| A developer runs composer create-project codeigniter4/appstarter myproject in the terminal. What is the most likely purpose of this command? | To create a new CodeIgniter 4 project using Composer |
| Given the route $routes->get('/profile/(:num)', 'Pages::profile/$1');, which URL would correctly trigger this route? | /profile/25 |
| A CodeIgniter View file can only contain plain HTML and is not allowed to include any PHP code. | False |
| In the MVC pattern, which component is responsible for directly interacting with the database to retrieve or store data? | Model |
| Route definitions in CodeIgniter are typically written in the file app/Config/Routes.php. | True |
| In the MVC pattern, the Controller is responsible for deciding which View is displayed in response to a request. | True |
| A controller currently has public function about() { return view('about'); }. A developer wants the About page to also display the current year automatically. What is the correct way to do this? | Pass the year from the controller to the view using an array, e.g. return view('about', ['year' => date('Y')]); |
| A routes file contains $routes->get('/tasks', 'Tasks::index'); and, further down, another line $routes->get('/tasks', 'Tasks::list');. When a user visits /tasks, which method actually runs? | Tasks::index(), because CodeIgniter uses the first matching route it finds |
| What does MVC stand for in the context of web application architecture? | Model-View-Controller |
| What is the name of the function used inside a CodeIgniter controller to load a View file and optionally pass data to it? | view() |
| A student visits a page and gets a "404 Page Not Found" error, even though the controller method exists and runs without issue when tested directly. What is the most likely cause? | No route was defined for that URL and no default routing matched it |
| A view file is saved as app/Views/tasks/index.php, but a controller calls return view('Tasks/Index'); using different capitalization. This works on a Windows machine but fails once deployed to a Linux server. What does this reveal? | View lookups can be case-sensitive depending on the operating system, so the path passed to view() should match the actual file's case |
| A single controller can have multiple methods, each corresponding to a different route or page. | True |
| Which function is used inside a CodeIgniter controller method to load and return a View? | view() |
| In MVC, the Model is responsible for rendering HTML and displaying content to the user. | False |
| A controller method needs to send the value $name = 'Maria' to a view so it can be displayed. Which line correctly accomplishes this? | return view('profile', ['name' => $name]); |
| In a default CodeIgniter 4 installation, which folder should be set as the web server's document root for production hosting? | public |
| A developer writes all of an application's HTML directly inside controller methods using echo statements, without using any View files. Why is this generally considered poor practice under the MVC pattern? | It mixes presentation code with request-handling logic, making the application harder to maintain |
| A view file contains the line <h1><?= $title ?></h1>, but the page displays an "Undefined variable $title" error. What most likely caused this? | The controller did not pass title in the data array to view() |
| Why might a developer choose to use a web framework like CodeIgniter instead of writing an application in plain PHP? | Frameworks provide reusable structure and tools, reducing repetitive setup work |
| A team is deciding whether every URL should directly mirror internal controller and method names, or use custom, cleaner routes instead. What is the main benefit of defining custom routes? | Custom routes let you design URLs independently of internal class names, so public links do not break when internal code changes |
| What is the name of the PHP dependency manager commonly used to install CodeIgniter 4? | Composer |
| Which of the following best describes the role of a View in MVC? | It focuses only on presentation and displaying data |
| What is the purpose of the .htaccess file in the public folder of a CodeIgniter project? | It removes index.php from the URL through URL rewriting |
| Every folder inside a CodeIgniter 4 project is meant to be publicly accessible from the web server. | False |