0
0
PHPprogramming~10 mins

Aliasing with as keyword in PHP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to alias the class OriginalClass as AliasClass.

PHP
<?php
use Some\Namespace\OriginalClass [1] AliasClass;

$obj = new AliasClass();
?>
Drag options to blanks, or click blank then click option'
Arename
Bas
Calias
Dwith
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alias' instead of 'as' keyword.
Trying to rename the class without 'as'.
2fill in blank
medium

Complete the code to alias the function originalFunction as aliasFunction.

PHP
<?php
use function Some\Namespace\originalFunction [1] aliasFunction;

aliasFunction();
?>
Drag options to blanks, or click blank then click option'
Ause
Balias
Crename
Das
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rename' or 'alias' instead of 'as'.
Omitting the 'as' keyword.
3fill in blank
hard

Fix the error in aliasing the constant ORIGINAL_CONST as ALIAS_CONST.

PHP
<?php
use const Some\Namespace\ORIGINAL_CONST [1] ALIAS_CONST;
echo ALIAS_CONST;
?>
Drag options to blanks, or click blank then click option'
Aas
Balias
Crename
Dconst
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alias' or 'rename' instead of 'as'.
Trying to use 'const' keyword again.
4fill in blank
hard

Fill both blanks to alias a class and a function from the same namespace.

PHP
<?php
use Some\Namespace\OriginalClass [1] AliasClass;
use function Some\Namespace\originalFunction [2] aliasFunction;

$obj = new AliasClass();
aliasFunction();
?>
Drag options to blanks, or click blank then click option'
Aas
Balias
Crename
Duse
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keywords for class and function aliasing.
Omitting the alias keyword.
5fill in blank
hard

Fill all three blanks to alias a class, a function, and a constant from the same namespace.

PHP
<?php
use Some\Namespace\OriginalClass [1] AliasClass;
use function Some\Namespace\originalFunction [2] aliasFunction;
use const Some\Namespace\ORIGINAL_CONST [3] ALIAS_CONST;

$obj = new AliasClass();
aliasFunction();
echo ALIAS_CONST;
?>
Drag options to blanks, or click blank then click option'
Aas
Balias
Crename
Duse
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keywords for different types of imports.
Forgetting to alias constants properly.