Why would I use PHP to Hide Information?
<?php
function foo($bar) {
echo $bar;
}
foo('foobar');
?>
VERSUS
<?php
class foo {
private $bar;
function __construct($b){
$this->bar = $b;
}
function display() {
echo $this->bar;
}
}
$foobar = new foo('bar');
$foobar->display();
?>
Whatever you publish becomes your public contract. Other people start to depend on your public methods, use them and expect them to be there and work the same. 'Other people' maybe yourself half a year later.
So be extremely conservative in what to make public. It gives you the freedom to evolve your code and fix bugs in it without breaking the public interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With