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 / dinesh kumar
function swap($x,$y)
{
$x^=$y^=$x^=$y;
return array($x,$y);
}
list($a,$b)=swap(5,10);
echo $a;
echo $b;
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is factory pattern in php?
Tell us what is the difference between session_unregister() and session_unset()?
Why framework is used in php?
How can we check the value of a given variable is alphanumeric?
Which php framework is best for beginners?
Is echo a function in php?
What is php destruct?
What is http php?
What are sql injections, how do you prevent them and what are the best practices?
How do you destroy a particular or all Sessions?
What the limitation of header() function in php?
What is $_ request in php?
How to specify argument default values?
How to get the number of characters in a string?
What is csrf validation?