Complete the code to declare a namespace named MyApp.
<?php namespace [1]; class User {}
The namespace keyword is followed by the namespace name, here MyApp.
Complete the code to use the class User from the namespace MyApp.
<?php
use [1]\User;
$user = new User();
The use statement imports the class User from the namespace MyApp.
Fix the error in the code by completing the blank to refer to the global class Exception.
<?php try { throw new \[1]("Error occurred"); } catch (\Exception $e) { echo $e->getMessage(); }
The global Exception class must be referenced with a leading backslash to avoid namespace conflicts.
Fill both blanks to create a namespace and define a class inside it.
<?php namespace [1]; class [2] {}
The namespace is App and the class defined inside is Product.
Fill all three blanks to import a class and create its instance.
<?php use [1]\[2]; $obj = new [3]();
The class User from namespace MyApp is imported and instantiated.
