Every time I get a variable through $_GET I want to verify that it is indeed an object of the User class.
So:
if (isUser($_GET['valid_user']))
{
...
}
is there a built in function to use instead of this so called "isUser"?
Thanks a lot!
You can verify any variable for a certain class:
if ($my_var instanceof classname)
however, in your case that will never work, as $_GET["valid_user"] comes from the request and is never going to be an object.
isUser() is probably a custom function from a user management library that authenticates the current session. You need to take a look how that works if you want to replace it.
There is a function in the PHP language, which might help you:
bool is_a ( object $object , string $class_name )
From the documentation: Checks if the object is of this class or has this class as one of its parents
you could try this:
if (is_object($_GET['valid_user']))
{
// more code here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With