I am trying pass a value inside stripe function function calculateOrderAmount(array $items): int
using variable declared outside function, but its not working. But if I declare variable inside the function function calculateOrderAmount(array $items): int
its working. Its confusing.
What is working
function calculateOrderAmount(array $items): int {
// assign session amount to a variable
$amount = 500;
return $amount;
}
What is not working and what I want
$amount = 500;
function calculateOrderAmount(array $items): int {
// assign session amount to a variable
return $amount;
}
I am trying to pass a value to the function from outside, kindly help