downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Classkit> <property_exists
[edit] Last updated: Fri, 17 May 2013

view this page in

trait_exists

(No hay información de versión disponible, podría estar únicamente en SVN)

trait_existsComprobar si el trait existe

Descripción

bool trait_exists ( string $traitname [, bool $autoload ] )

Parámetros

traitname

Nombre del trait a comprobar

autoload

Si aplicar la autocarga si no está ya cargado.

Valores devueltos

Devuelve TRUE si el trait existe, FALSE si no, NULL en caso de error.



add a note add a note User Contributed Notes trait_exists - [1 notes]
up
0
mr dot ryansilalahi at gmail dot com
10 days ago
<?php

trait common{
   
    function
shout(){
        return
'hello world!';
    }
}

class
a{
    use
common;
}

class
b{
    use
common;
}
if(
trait_exists('common')) {
        echo (new
a())->shout();
}
if(
trait_exists('common')) {
        echo (new
b())->shout();
}

 
show source | credits | stats | sitemap | contact | advertising | mirror sites