A question about function()

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
zakhar
Posts: 179
Joined: 08 Sep 2010 21:13

A question about function()

Post by zakhar »

Hello, dear forum!

I have the following question:

Code: Select all

 $a = 0;
 func($a);
 echo 3 $a;
 
 function func($a){
    echo 1 $a;
    $a += 1;
    echo 2 $a;
    return $a;
 }
In the code above how can I get the $a in "echo 3 $a;" to be the same as in the "echo 2 $a;" ?
The problem in other words: I can submit $a from "$a = 0;" through the "func($a);" into the "function func($a){}",
but not backwards from "function func($a){}" to the "echo 3 $a;".

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: A question about function()

Post by highend »

By assigning your func() call result to $a

$a = func($a);
One of my scripts helped you out? Please donate via Paypal

zakhar
Posts: 179
Joined: 08 Sep 2010 21:13

Re: A question about function()

Post by zakhar »

Wow!
Thank you, highend!

Post Reply