I have a class:
class FetchMode
{
const FetchAll = 0;
const FetchOne = 1;
const FetchRow = 2;}
and a function:
function get
I don't know what you mean by
would like to offer a list of possible choices in calling a function. Is it possible in php?
but for the error part: Imagine you have a var, e.g. $foo
. When you do echo $foo
you don't get the name of the var but its value. This is because a var has a name and points to a value. Every access to the var basically returns the value it points to. Its the same with constants; You put the constant name in there, but basically you are pointing to your stored value. Which means getRecordSet(FetchMode::FetchOne);
and getRecordSet(1);
is the same.
So, getRecordSet(FetchMode $FetchMode)
raises must be an instance of FetchMode
because FetchMode::FetchOne
points to an integer.
To fix this, you need to use getRecordSet(int $FetchMode)
.