Friday, October 10, 2025
HomeLanguagesPHP | ReflectionClass isInstantiable() Function

PHP | ReflectionClass isInstantiable() Function

The ReflectionClass::isInstantiable() function is an inbuilt function in PHP which is used to check the specified class is instantiable or not.

Syntax:

bool ReflectionClass::isInstantiable( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns TRUE if the specified class is instantiable, otherwise return FALSE.

Below programs illustrate the ReflectionClass::isInstantiable() function in PHP:

Program 1:




<?php
  
// Initializing a user-defined Class Departments
class Departments {
    public function CSE() { }
}
  
// Using ReflectionClass() over the
// user-defined class Departments
$class = new ReflectionClass('Departments');
  
// Calling the isInstantiable() function
$instance = $class->isInstantiable();
  
// Getting the value true or false
var_dump($instance);
?>


Output:

bool(true)

Program 2:




<?php
  
// Initializing a interface named as TestFunction
interface TestFunction {
    function F1();
    function F2();
}
  
// Using ReflectionClass() over the
// specified interface
$class = new ReflectionClass('TestFunction');
  
// Calling the isInstantiable() function and
// getting the value true or false
var_dump($class->isInstantiable());
?>


Output:

bool(false)

Reference: https://www.php.net/manual/en/reflectionclass.isinstantiable.php

RELATED ARTICLES

Most Popular

Dominic
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7100 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS