Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to use the method getStaticPropertyValue and it is failing claiming that the static property doesn't exist but it does. Code: // Fails $strValue = $objReflect->getStaticPropertyValue('tableName'); // Shows ...
  1. #1
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,300

    PHP5 - Reflection API getStaticPropertyValue()

    I am trying to use the method getStaticPropertyValue and it is failing claiming that the static property doesn't exist but it does.

    Code:
    //  Fails
    $strValue = $objReflect->getStaticPropertyValue('tableName');
    
    //  Shows that tableName does indeed exist
    foreach ($objReflect->getStaticProperties() as $name => $value) {
        echo "$name = $value<br>";
    }
    I know I can use an if in the loop to get at the value of the property I want and that is what I am going to do for now, but there must be some reason why getStaticPropertyValue() is failing. I would like to understand what (if anything) I am doing wrong.

    In case it is important, the static property is defined in a sub-class of the class that is trying to access it.
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  2. #2
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,300
    OK, I redesigned the classes to avoid the static method and used a class constant and the getConstant() method of the ReflectionClass class.

    It works now
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...