Durante una revisione del codice, ho trovato qualcosa di simile a questo:
function foo() {
$a = "a";
$expression = '$_GET["$a"]';
return eval('return ('.$expression.');');
}
$a = foo();
echo $a;
Non importa le assurdità, l'esempio è semplificato e, a causa di cattive decisioni di progettazione, il cliente ha "veramente" bisogno dell'istruzione "return repal".
La mia ipotesi sarebbe no, perché $expression non è $_GET["$a"] , ma una stringa che rappresenta il nome della variabile, quindi l'argomento a eval() è equivalente a una "stringa di ritorno".
Ma secondo il manuale PHP:
You should never use parentheses around your return variable when returning by reference, as this will not work. You can only return variables by reference, not the result of a statement. If you use
return ($a);then you're not returning a variable, but the result of the expression($a)(which is, of course, the value of$a).
C'è un modo in cui questo potrebbe essere sfruttato?