ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What will be the values of $a and $b after the code below is executed? Explain your answer.

user-image
تم إضافة السؤال من قبل Anirban Chakraborty , Network Administrator , Wipro Limited
تاريخ النشر: 2017/01/17
ibrahim badran
من قبل ibrahim badran , Front & Backend Developer , Freelancer

$a is variable having string as type and contain 1 as value, $b is reference of $a so if we change the value of $b that value of $a is changed automatically because both having the same value.

So $b = '2$b'  = '21' = $a .

مستخدم محذوف‎
من قبل مستخدم محذوف‎

Answer here ......................

Adel Ezat Fawzy Ellozy
من قبل Adel Ezat Fawzy Ellozy , Webdeveloper. , Saudi Arabian Maritiem Sports Federation

$a = '1';   // '1' as string .

$b = &$a; // $b reference to $a

So Both are equal to "21" ;

Jonathan de Flaugergues
من قبل Jonathan de Flaugergues , software engineer , Abbeal

$a = '1'; // $a is a variable type of string with the value '1';

$b = &$a; // $b is the reference of the $a variable.

$b = "2$b"; // $b & $a have for value the string '2' concatenate with the value of the variable $a (string '1')

So, the result is '21'

Ehab  Shaker
من قبل Ehab Shaker , Dot Net Developer , Info Strategic

the result is '21' as a string value

هاشم المشارقة
من قبل هاشم المشارقة , Key Account Manager , Advanced United Systems Ltd. ( A member of Taj Holding Group)

Pay attention to tha last line of the code.

$b = "2$b" (String)

المزيد من الأسئلة المماثلة