Php Script To Swap Two Numbers

 

Create A form for inputting Purpose

(swp.html)


<!DOCTYPE html>

<html>

<form method="POST" action="swap.php">

Enter first number:<input type="text" name="n1">

Enter second number:<input type="text" name="n2">

<input type="submit">

</form>

</html>





Embed Php File

(swp.php)

<?php

$a=$_POST["n1"];

$b=$_POST["n2"];

$t=$a;

$a=$b;

$b=$t;

echo $a,"\n";

echo $b;

?>





Comments