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 / ranjan
function swap(){
$a = 10;
$b = 20;
$a = $a + $b;
$b = $a - $b;
$a = $a - $b;
echo $a, $b;
}
| Is This Answer Correct ? | 45 Yes | 25 No |
Post New Answer View All Answers
What are different types of errors available in Php?
What are the main error types in php and how do they differ?
Can you use both this () and super () in a constructor?
Explain what is the difference between for and foreach?
Can we use include ("xyz.php") two times in a php page "index.php"?
Is empty function c++?
Tell me can the value of a constant change during the script's execution?
Do you know how can we check the value of a given variable is a number?
Which methods should be used for sending an email using the variables $to, $subject, and $body?
What are php libraries?
Explain scalar type declarations in php7?
Distinguish between urlencode and urldecode?
What is array and function?
Can we extend multiple classes in php?
What is use of isset function in php?