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 / vivek srivastava
<?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 ? | 31 Yes | 8 No |
Post New Answer View All Answers
What is php trait?
Tell me what should we do to be able to export data into an excel file?
What is stripslashes php?
How long does a session last in php?
What is advanced php programming?
Which is the dependent variable?
I need to know about the courses which are useful in corporate companies.. especially php/mySQL, Java/j2ee, .NET.. also tell if any other courses are valuable
How to open standard output as a file handle?
What is the use of count() function in php?
Do you know what is the difference between mysql_fetch_object() and mysql_fetch_array()?
What is difference between static and constant in php?
What are the functions to be used to get the image's properties (size, width and height)?
How can we connect to a mysql database from a php script?
How can we automatically escape incoming data?
Write a program in php to check whether a number is prime or not?