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

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

متابعة

Any one explain to me whats the logic behind this code?

<p>&lt;?php$sample="example";$tranc=&amp;$sample;$tranc="output";echo $sample;echo $tranc;?&gt;output is output output</p>

user-image
تم إضافة السؤال من قبل Kamatchi Panneer Selvam , Software Developer , Comtel General Trading LLC
تاريخ النشر: 2014/10/13
Jubayer Arefin
من قبل Jubayer Arefin , Software Developer , Squidoan

=& operator is used to get a reference of a variable. In this case $tranc has a reference of $sample. Try changing the value of $tranc and echo again. You will see the difference.

 

Cheers

Ali Imran
من قبل Ali Imran , Application Development Manager , TekGenisys

$tranc holds address of $sample (i.e. & basically is used for memory address / reference), thus points to what $sample holds, but the3rd statement is an assignment to $tranc so previous pointer wont work.Now echo'ing $sample will output "example", and $tranc will output the word "output".As far the text after closing tags "?>" will simply be output to client application either browser or whatever.

 

 

I hope you understood.

 

regards

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