Topic: Class help get instance name (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Topic: Class help get instance name (Page 1 of 1)" rel="nofollow" >Topic: Class help get instance name <span class="small">(Page 1 of 1)</span>\

Bipolar (III) Inmate

Insane since: Jun 2003

IP logged posted posted 01-06-2010 18:37 Edit Quote

Problem im trying to write reusable code that will automatically get the instance name.


class Object() {
public static nulls = array(blah blah blah);

public static function fill_nulls($post, $object_name){
foreach(static::$nulls as $key => $val){
if($post[$val] == '' || !isset($post[$val])){
$$object_name->$key = "NULL";	


$object = new Object();

instead of setting a variable to be the name of the object is there a way to dynamiclly get the name of the new object so if the name changes the code doesnt have too?

Nervous Wreck (II) Inmate

Insane since: Apr 2008

IP logged posted posted 01-13-2010 14:25 Edit Quote

Not sure what you are trying to achieve. You can get the class name

Else you should use custom getters/setters imo.
Declare a "holder" variable private and create public methods to access it, get value, set value.


Post Reply
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
Your Text:
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu