I'd like to pass (any type, not only PHP's primitives) Type as a function parameter. More like a C++'s template. Is it possible in PHP? imaginary code:
function foo(T a){ $output = new T(); //do something.}
I tried pass the type name as string and then use settype()
to the the variable to that type but settype()
work only with PHP's primitives types. My goal is actually pass a class type as parameter.