I have a problem with passing variables as reference in PHP.
I want to set $grand_total after:
$data = array('title' => 'blabla', 'value' => &$grand_total);
// Set after
$grand_total += 50;
This is running without a problem, but when I pass $grand_total var using a function, I get the error below:
PHP Error was encountered Severity: 8192 Message: Call-time
pass-by-reference has been deprecated Filename:
controllers/checkout.php Line Number: 131
I’m passing the variable like this:
$data = array('title' => 'blabla', 'value' => price(&$grand_total));
// Set after
$grand_total += 50;
I must use the price() function.
Can anyone help me?
I’m sorry for my bad English.
This would work perfectly fine for you
Output
For more Information
https://www.php.net/manual/en/language.references.php
https://www.php.net/manual/en/language.references.pass.php
Thanks
🙂