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 / binoyav

The above answer is correct. But the interviewer does not
want to echo the values from inside the function. It should
be in the following way
$a = 10;
$b = 20;
echo $a, $b;
swap(); // Here if you want you can pass the variables
echo $a, $b;

function swap()
{
}

Is This Answer Correct ?    8 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between php traits vs interfaces?

489


Explain what is the difference between $var and $$var?

527


How do I repair phpmyadmin?

523


How is it possible to parse a configuration file?

511


What is laracast?

586






What is the purpose of basename() function in PHP?

602


How to redirect a url from http to https in .htaccess?

523


What are interfaces in php?

521


What is the difference between print() and echo() in PHP?

570


What are the string functions in php?

526


What is the alternative structure for control structures?

593


What is the mysql injection?

555


How does the identity operator === compare two values?

677


What php framework does wordpress use?

545


What is php key?

513