<?php function my_func($my_var){ ... } $a = 20; my_func($a); echo $a; //здесь должно быть выведено 30 

According to this part of the code, you need to finish it so that the function increases the value of $ my_var by 10. It is prohibited to use return in the function.

  • Pass on the link? - pavel
  • and how to avoid the absence of a return? You know? pliz write then - Beginner
  • Have you tried to do this with links? Show what you did and did not work, the answer will look like a mockery. php.net/manual/ru/language.references.pass.php - pavel
  • Pavel, I understand, thanks. Don't know that this will work without return - Beginner
  • function my_func (& $ my_var) {$ my_var + = 10; } - The Beginner

1 answer 1

We use the reference:

 function my_func(&$my_var){ $my_var += 10; } $a = 20; my_func($a); echo $a;