Problem:- How to Pass Value by Reference in Function? You want to pass a variable to a function and have it retain any changes made to its value inside the function.
Solution – Pass Value by Reference in Function
<?php function wrap_in_html_tag(&$text, $tag='em'){ $text = "<$tag>$text</$tag>"; } ?>
How it Works?
Passing a variable to a function by reference allows you to avoid the work of returning the variable and assigning the return value to the original variable. It also useful when you want to function to return a Boolean success value of true and false.
इसे भी पढ़े – Photoshop में Blur Tool और Dodge Tool