PHP: Check if a variable is an instance of a certain class

php

Solution

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.

Problem

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!

Original source