Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a namespace named MyApp.
PHP
<?php namespace [1]; class User {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or underscores instead of the exact namespace name.
Adding extra backslashes or characters.
✗ Incorrect
The correct syntax to declare a namespace is namespace MyApp; with the exact name.
2fill in blank
mediumComplete the code to declare a nested namespace named App\Controllers.
PHP
<?php namespace [1]; class HomeController {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using forward slashes or dots instead of backslashes.
Using underscores instead of backslashes.
✗ Incorrect
Namespaces in PHP use backslashes \ to separate levels, so App\Controllers is correct.
3fill in blank
hardFix the error in the namespace declaration syntax.
PHP
<?php [1] MyApp; class Product {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Capitalizing the keyword.
Adding a semicolon after the keyword.
✗ Incorrect
The keyword to declare a namespace is namespace all lowercase without a semicolon after it.
4fill in blank
hardFill both blanks to declare a namespace and define a class inside it.
PHP
<?php [1] [2]; class Order {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a semicolon after the keyword in the first blank.
Using an incorrect namespace name.
✗ Incorrect
The correct syntax is namespace OrderApp; to declare the namespace.
5fill in blank
hardFill all three blanks to declare a nested namespace and define a class inside it.
PHP
<?php [1] [2]\[3]; class Customer {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Capitalizing the keyword.
Using forward slashes or dots instead of backslashes.
Adding extra characters or spaces.
✗ Incorrect
The correct syntax is namespace App\Models; with lowercase keyword and backslash separator.