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
What is beforeRender() used?
Tell me how can we determine whether a variable is set?
How can we submit form without a submit button?
How to create database connection and query in php?
Do you know what are traits?
Which escape sequences can be used in single quoted strings in php?
Applications written to provide a GUI shell for Unix and Linux are called
What are the data types in php?
What is static variable in php?
What is an array in php?
What do the initials of php stand for?
How to execute a function in php?
What are the environmental variables?
How long is session timeout?
What are the differences between GET and POST methods?