ধরুন, আমাদের মানটি হলো—
$nextValue = 100;
নতুন একটি ভেরিয়েবল নিয়ে রেফারেন্স অ্যাসাইন করুন—
$currentValue = &$nextValue;
রেফারেন্স অ্যাসাইন করতে PHP-এ রেফারেন্স অ্যাসাইনমেন্ট অপারেটর অর্থাৎ =&$anyVariableName ব্যবহার করুন।
PHP কোডটি নিচে দেওয়া হলো—
উদাহরণ
<!DOCTYPE html> <html> <body> <?php $nextValue = 100; $currentValue = &$nextValue; echo "Next Value = ", $nextValue, "<br>"; echo "Current Value = ", $currentValue, "<br>"; $nextValue = 45000; echo "After changing the value of next will reflect the current value because of =&", "<br>"; echo "Next Value = ", $nextValue, "<br>"; echo "Current Value = ", $currentValue; ?> </body> </html>
আউটপুট
Next Value = 100 Current Value = 100 After changing the value of next will reflect the current value because of => Next Value = 45000 Current Value = 45000