Usephul

Traits

Table of Contents

Functions

uses()  : bool
Checks whether an object or class uses a given trait.

Functions

uses()

Checks whether an object or class uses a given trait.

uses(object|string $object_or_class, string $trait[, bool $allow_string = true ]) : bool
Parameters
$object_or_class : object|string

A class name or an object instance.

$trait : string

The trait name.

$allow_string : bool = true

If this parameter set to false, string class name as object_or_class is not allowed. This also prevents from calling autoloader if the class doesn't exist.

Return values
bool

This function returns true if the object_or_class, or any of its traits, uses trait or if any of its parents, or its parents' traits, use trait.


        
On this page

Search results