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 / naresh
$a=10;
$b=10;
list($a,$b) = array($b, $a);
echo "a=" . $a;
echo "b=" . $b;
| Is This Answer Correct ? | 7 Yes | 1 No |
Post New Answer View All Answers
Explain the difference between urlencode and urldecode?
How can we submit a form without using submit buttons?
Can we use onclick in submit button?
What is the difference between client-side and server-side programming?
Explain how can we execute a php script using command line?
What is use of header() function in php?
How many escape sequences are recognized in double-quoted strings?
What is mysqli_real_escape_string?
What are the difference between array_keys() and array_key_exists() in php?
When do sessions end?
How can a cross-site scripting attack be prevented by php?
Is php closing tag necessary?
How to get a total number of elements used in the array?
What is active record in php?
How to access a Static Member of a Class in PHP?