[HELP] Single questions & Help Thread [n00b] (66)

28 Name: #!/usr/bin/anonymous : 2008-06-11 22:22 ID:V7mp15x0

>>27
I guess OOP is more about design than security.
I did figure out how to prevent that >>26 from working.
If you declare members of a class static and private and use protected methods to handle them, then you can prevent their visibility (in this case).

<?php
class foo {

  private static $key = "password";
  protected function show() {
echo( self::$key );
}

}

$obj = new foo();
$a = (array)$obj;
echo $a; // An empty array gets printed
echo foo::$key; // Fatal error
echo $obj->key; // Fatal error
foo::show(); // Fatal error
$obj->show(); // Prints key as expected
?>

So it seems that $key is nicely hidden this way.

This thread has been closed. You cannot post in this thread any longer.