Write a program to swap two numbers using php.
Answer / Aqib Ashhar
Here's a simple PHP script that swaps the values of two variables:
```php
$num1 = 10;
$num2 = 20;
// Swap the values
$temp = $num1;
$num1 = $num2;
$num2 = $temp;
echo "Num1: {$num1}n";
echo "Num2: {$num2}";
```
This script first stores the value of `$num1` in a temporary variable, then assigns the value of `$num2` to `$num1`, and finally assigns the value of the temporary variable (previously containing `$num1`) to `$num2`. The final output will be:
```
Num1: 20
Num2: 10
```
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain the differences between get and post methods?
what is Opern source?
Is php used for frontend or backend?
Why php script is not running in browser?
What and How possible injection in PHP and mysql?
How many days will it take to learn php?
What is a query in a database?
How can we determine whether a variable is set?
What is the use of pear in php?
What does a special set of tags do in php?
What is cookie in php with example?
How is it possible to parse a configuration file?