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


Please Help Members By Posting Answers For Below Questions

How you can update memcached when you make changes to php?

623


Is empty java?

544


Which programming language does php resemble to?

551


What is php and features of php?

454


What is properties of class?

594






What are the special characters you need to escape in double-quoted stings?

545


Tell me will a comparison of an integer 12 and a string "13" work in php?

658


How to create a table to store files?

559


What is $globals php?

541


Are there regular expressions in php?

483


What is array and function?

537


What is in php 7?

563


What is instantiation?

1748


Which php global variable is used for uploading a file?

512


How to remove values saved in the current session?

539