(&$a) in method/function headers?
bla.php:
<?php
function bla_init(&$a) {
$a->doSomething();
}
Why & here? Is this an old way of code style? Well, it allows me to modify $a into anything I want, also something incompatible, like this:
bad.php:
<?php
function bad_init(&$a) {
$a = 'Something else';
$a = 0.0001; // Also works!
}
You really don't want this! Better use this:
better.php
<?php
function better_init(App $a) {
$a->doItSecurely();
}
Now you (the naughty programmer) cannot change $a into something nasty anymore.
Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •Roland Häder🇩🇪
in reply to Roland Häder🇩🇪 • •