Page 1 of 1
need get_class() equivalent that preserves case
Posted: Mon Jul 12, 2004 10:51 pm
by xandor
My hosting service uses PHP 4.2 and when I call get_class() it returns the classname in all lower case. Does anybody know a workaround for this? I'm just passing an instance of a class and need its name. I've tried print_r, gettype, and even serialize() and they all behave the same way!
Anywhere else to hack into it?
Posted: Sat Jul 17, 2004 8:42 am
by kettle_drum
This is what get_class() does in this version of php (changes in php 5). One work around would be to have a convention when naming your classes - ALL_CAPS, First_case_cap, all_lower - and then you can simply call get_class() and do the required formating - strtoupper...etc.
Posted: Sat Jul 17, 2004 10:03 am
by feyd
alternately, you could use a convention where you store the name of the class in its declaration.. i.e.
Code: Select all
<?php
class fOO
{
var $classname = "fOO";
}
// or
class bAr
{
function get_class()
{
return "bAr";
}
}
?>