Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal, bom dia!
Eu tenho essa função que funciona muito bem quando não está dentro de uma classe.
function objectToArray($d)
{
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}
if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return array_map(__FUNCTION__, $d);
// return array_map(objectToArray, $d);
} else {
// Return something diferent that array
return $d;
}
}
Quando coloco dentro de uma classe
class Functions{
function objectToArray($d)
{
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}
if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return array_map(__FUNCTION__, $d);
// return array_map(objectToArray, $d);
} else {
// Return something diferent that array
return $d;
}
}
}
Simplesmente ele dá erro
Carregando comentários...