Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



1. Write a function to swap two values ? $a = 10; $b = 20; echo $a, $b; swap(); // If u want u c..

Answer / ajay

I checked the answer posted by Sunil. This answer is
correct,the only mistake he did that the program print the
output together as 1020,2010,not like this
10
20


20
10

Is This Answer Correct ?    2 Yes 2 No

1. Write a function to swap two values ? $a = 10; $b = 20; echo $a, $b; swap(); // If u want u c..

Answer / meenakshisundaram

$a = 10;
$b = 20;
echo $a, $b;
swap();
echo $a, $b;

swap(){
list($a, $b) = array($b, $a);
}

Is This Answer Correct ?    1 Yes 1 No

1. Write a function to swap two values ? $a = 10; $b = 20; echo $a, $b; swap(); // If u want u c..

Answer / sangita jain

<?php function swap(){
$a=10;
$b=20;
$b=$b-$a;
$a=$a+$b;
echo $a,$b;
}

swap();

?>

Is This Answer Correct ?    0 Yes 2 No

1. Write a function to swap two values ? $a = 10; $b = 20; echo $a, $b; swap(); // If u want u c..

Answer / ramse

One way is:

function swap($x, $y) {
$x ^= $y ^= $x ^= $y;
return array($x,$y);
}

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More PHP Interview Questions

What is the difference between exception::getmessage and exception::getline?

0 Answers  


Explain about PHP cookies?

0 Answers  


how to store case sensitive data in mysql ? how repair mysql table? diff bet float, double,real? diff bet mysql_fetch_object() and mysql_fetch_array()? which version of mysql support procedure , trigger? diff php4 and php 5? op - 2+5+"8"=? how to create object in javascript? query - select games from team who won games 2/4/6? NaN command in php? How to offload System date in mysql? typecasting in php? how to convert string to two decimal no? how to parse xml file in php command line argument in php? diff bet $msg,$$msg? diff bet require(), include(), include_once()? tables in mysql?

2 Answers   Aloha Technology,


What are psrs?

0 Answers  


What are the differences between mysqli_connect and mysqli_pconnect?

0 Answers  


What is php addslashes?

0 Answers  


How can we encrpt a text?

3 Answers  


What is singleton class in php?

0 Answers  


How do I escape data before storing it into the database?

0 Answers  


What is the difference between characters  and #?

0 Answers  


What is meant by ‘passing the variable by value and reference' in php?

0 Answers  


which will print out the php call stack?

0 Answers  


Categories