Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Anirban Chakraborty , Network Administrator , Wipro Limited
Date de publication: 2017/01/17
ibrahim badran
par 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 .

Utilisateur supprimé
par Utilisateur supprimé

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

Adel Ezat Fawzy Ellozy
par 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
par 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
par Ehab Shaker , Dot Net Developer , Info Strategic

the result is '21' as a string value

هاشم المشارقة
par هاشم المشارقة , 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)

More Questions Like This