emehrkay Posted February 7, 2008 Share Posted February 7, 2008 I dont know what it is called exactly, but you know what I'm talking about (this is the reason why I'd probably fail the cert exam). Anyway, when you cast the type of data that a function variable should be, can you specify an object? I've tried a few things function foo((object) array $bar = array()){} //cannot cast function foo((object) $bar = array()){} //cannot cast function foo(object $bar){} //cannot instanciate class $bar Is it even possible? thanks Quote Link to comment https://forums.phpfreaks.com/topic/89953-is-it-possible-to-cast-a-function-variable-as-an-ojbect/ Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 Been doing a little research and nothing says you can't, or can. Quote Link to comment https://forums.phpfreaks.com/topic/89953-is-it-possible-to-cast-a-function-variable-as-an-ojbect/#findComment-461238 Share on other sites More sharing options...
emehrkay Posted February 7, 2008 Author Share Posted February 7, 2008 I've just been casting it inside of the function, but I wonder why you're not able to limit it in the params function foo(array $bar = array()){ $bar = (object) $bar; } Quote Link to comment https://forums.phpfreaks.com/topic/89953-is-it-possible-to-cast-a-function-variable-as-an-ojbect/#findComment-461277 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.