Write a PHP program to swap two variables


Introduction

PHP is a server scripting language, and It is a powerful tool for making interactive and dynamic Web-pages. I have used WampServer 2.2 for following excercise..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. <?php
  2. $num1 = 20;
  3. $num2 = 30;
  4.  
  5. echo "\nThe number before swapping is:\n";
  6. echo "num1 = ".$num1." and num2= ".$num2 ;
  7.  
  8. $temp = $num1;
  9. $num1 = $num2;
  10. $num2 = $temp;
  11.  
  12. echo "\nThe number after swapping is: \n";
  13. echo "num1 = ".$num1." and num2= ".$num2."\n";
  14. ?>

Result

python language techstudy.org

     





Related Topics




Popular Posts