কম্পিউটার টিউটোরিয়াল

PHP-এ রেফারেন্স অ্যাসাইনমেন্ট অপারেটর দিয়ে রেফারেন্স অ্যাসাইন করা


ধরুন, আমাদের মানটি হলো—

$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

  1. PHP-এ next() ফাংশন

  2. C#-এ অ্যাসাইনমেন্ট অপারেটর (Assignment Operator) কী?

  3. C#-এ অ্যাসাইনমেন্ট অপারেটর (Assignment Operator) ব্যবহার করা

  4. পাইথনে ভেরিয়েবলে রেফারেন্স অ্যাসাইন করা যায় কি?