1. Write a function to swap two values ?
$a = 10;
$b = 20;
echo $a, $b;
swap(); // If u want u can pass parameters
echo $a, $b; // It should print 20 , 10
Answer Posted / ankush sharma
<?php
$a=10;
$b=20;
echo $a,$b;
echo "<br>";
swap($a, $b);
echo "<br>";
echo $a,$b;
function swap(&$a, &$b)
{
$a = $a + $b;
$b = $a - $b;
$a = $a - $b;
}
?>
| Is This Answer Correct ? | 14 Yes | 2 No |
Post New Answer View All Answers
What is the use of header in php?
How to get the directory name out of a file path name?
What does a delimiter do in mysql?
What are the features of object-oriented programming in php?
Why do we use php?
What is static method php?
Explain PHP?
What is the use of super-global arrays in php?
How can we connect to a mysql database from a php script?
What is phpsessid?
Tell me how comfortable are you with writing html entirely by hand?
What is mysqli php?
What is the difference between $argv and $argc? Give example?
How to run a php script?
What is get method in java?