Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the class MyClass from the namespace App\Utils.
PHP
<?php
use App\Utils\[1];
$obj = new MyClass(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the namespace instead of the class
Forgetting to use the full namespace path
✗ Incorrect
The
use keyword imports the class name. Here, MyClass is the class to import.2fill in blank
mediumComplete the code to import the Helper class from the Library\Tools namespace.
PHP
<?php
use Library\Tools\[1];
$helper = new Helper(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the namespace name instead of the class
Misspelling the class name
✗ Incorrect
You must import the exact class name
Helper after the namespace.3fill in blank
hardFix the error in the import statement to correctly import Database\Connection.
PHP
<?php
use Database\[1];
$conn = new Connection(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong class name
Adding extra letters or missing letters
✗ Incorrect
The class name is
Connection, so the import must match exactly.4fill in blank
hardFill both blanks to import Mailer from Services\Email and create an instance.
PHP
<?php use Services\[1]\[2]; $mail = new Mailer();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping namespace and class names
Using incorrect namespace parts
✗ Incorrect
The full namespace is
Services\Email\Mailer, so import both parts correctly.5fill in blank
hardFill all three blanks to import Logger from Framework\Utils\Log and create an instance.
PHP
<?php use Framework\[1]\[2]\[3]; $log = new Logger();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up namespaces and class names
Using plural forms incorrectly
✗ Incorrect
The full path is
Framework\Utils\Log\Logger, so fill blanks accordingly.