Just to explain why gettype() doesn't work as expected since others have already provided the correct answer. gettype() returns the type of variable โ i.e. boolean, integer, double, string, array, object, resource, NULL or unknown type (cf. the gettype() manual link above).
In your case the variable $campaign is an object (as returned by gettype()), and that object is an instance of the class Campaign (as returned by get_class()).
[RFC] typeof() in PHP 7.1
Alias for is_object($var) ? get_class($var) : gettype($var)
Here you go:
function get_real_type($var)
{
return is_object($var) ? get_class($var) : gettype($var);
}Do we really need to add another function to ext/standard for this?
More on reddit.comJust to explain why gettype() doesn't work as expected since others have already provided the correct answer. gettype() returns the type of variable โ i.e. boolean, integer, double, string, array, object, resource, NULL or unknown type (cf. the gettype() manual link above).
In your case the variable $campaign is an object (as returned by gettype()), and that object is an instance of the class Campaign (as returned by get_class()).
You can use get_class($object);
http://www.php.net/get_class
To help with your new situation (if I've understood properly)
<?php
namespace Ridiculous\Test\Whatever;
class example {}
$example = new example();
echo get_class($example) . '<br>';
echo basename(get_class($example)); // this may be what you're after