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
How you can update memcached when you make changes to php?
Is empty java?
Which programming language does php resemble to?
What is php and features of php?
What is properties of class?
What are the special characters you need to escape in double-quoted stings?
Tell me will a comparison of an integer 12 and a string "13" work in php?
How to create a table to store files?
What is $globals php?
Are there regular expressions in php?
What is array and function?
What is in php 7?
What is instantiation?
Which php global variable is used for uploading a file?
How to remove values saved in the current session?