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

Is age interval or ordinal?

742


What is mysqli_query?

725


What is factory pattern in php?

734


Does wordpress run on php 7?

730


How to reset/destroy a cookie?

858


Are objects passed by value or by reference?

770


What are arguments in php?

780


Why do we use php?

753


What does the function get_magic_quotes_gpc() means?

740


What beforeFilter() is used?

877


What is php dependency injection?

738


Is runtime polymorphism overriding?

704


How to open standard output as a file handle?

786


Tell us how can we display the output directly to the browser?

836


Write a program to show the joining of two strings in php?

763