Can you define an argument as a reference type?



Can you define an argument as a reference type?..

Answer / Amrit Kumar Vashistha

In PHP, there is no concept of passing arguments by reference directly. However, you can achieve this using the "&" operator before the function parameter. Here's an example:

```php
function changeValue(&$myVar) {
$myVar = 'new value';
}

$myVar = 'original value';
changeValue($myVar);
echo $myVar; // outputs 'new value'
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What is the best php version for wordpress?

1 Answers  


What is the output of the ucwords function in this example?

1 Answers  


Does php support multiple inheritance?

1 Answers  


What are the php functions?

1 Answers  


How many ways we can give the output to a browser?

6 Answers  


What are traits?

1 Answers  


What is the function of mysql_real_escape_string in php?

1 Answers  


Explain some most commonly use string functions in php?

1 Answers  


This question is regarding version control. If two developers are committing the same php file at same time what will happen ? What error it will show (if any) ?

2 Answers   TCS,


Tell me how can we automatically escape incoming data?

1 Answers  


What is static in php?

1 Answers  


what type of images that the PHP version supports

4 Answers  


Categories