PHP Interview questions


Total available count: 33
Subject - PHP Frameworks
Subsubject - PHP

What is the use of ::class?

Since PHP 5.5, the class keyword is also used for the class name resolution. You can get a string containing the fully qualified name of the ClassNames class by using ClassNames::class. This is particularly useful with namespaced classes.

Example: 

<?php
namespace NS {
class ClassNames {
}

echo ClassNames::class;
}
?>
The Output: NS\ClassNames

Note: Class name resolution using by ‘::class is a compile time transformation. That means at the time the class name string is created no autoloading has happened yet. As a consequence, class names are expanded even if the class does not exist. No error displays in that case.




Next 5 interview question(s)

1
Define inheritance and how it can be implemented in PHP?
2
What are Objects?
3
What are Classes?
4
What is an operator and how many types of operators are there?
5
What is the difference between named functions vs anonymous functions?