Skip to content

Instantly share code, notes, and snippets.

@samsamm777
Last active April 26, 2024 13:24
Show Gist options
  • Save samsamm777/7230159 to your computer and use it in GitHub Desktop.
Save samsamm777/7230159 to your computer and use it in GitHub Desktop.

Revisions

  1. samsamm777 revised this gist Oct 30, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <?php

    $a = new A();
    $reflection = new \ReflectionClass($a);
    $property = $reflection->getProperty('privateProperty');
    $property->setAccessible(true);
    $property->setValue($a, 'new-value');
  2. samsamm777 created this gist Oct 30, 2013.
    10 changes: 10 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?php

    $a = new A();
    $property = $reflection->getProperty('privateProperty');
    $property->setAccessible(true);
    $property->setValue($a, 'new-value');

    echo $a->getPrivateProperty();
    //outputs:
    //new-value