The scope of links?

Good time of day. On the Internet Umatilla stuck in holivar about references in PHP. In the course of the holivar sounded ~the following arguments:

1. Links from PHP's cut, in the version 5.0+ of them left as deprecated (I haven't found any evidence of this, in addition to "cutting out" someFunction( &link ) )

2. Use function someFunction( ¶m ){} contrary to the "concept function", because the only correct way to use function $some = someFunction( $some ). Any other code is "weird" and so not necessary to write.

3. Instead of foreach( $array as &value ){} you need to use either $array = array_map( 'func', $array ) or foreach( $array as $key => &value ){ $array[ $key ] = }.

4. Literally, "PHP 5 we asked the right behavior. Primitives exactly and need to pass a copy (that is, that it was impossible to affect the entity specified in the parameter)".

I such radical views on such a convenient and familiar mechanisms seem not adequate. I believe that each instrument its place. And what if the use of links allows you to simplify your code, make it "more readable", and also to enhance its performance, where this is a concern, then there is no reason to refuse them.

I'm not saying that all functions should accept arguments for the links, or that code of the form $array = some( $array ) is bad, I claim that "everything has its place". But I was under the impression that this position is no longer "fashionable", and use the links even in the foreach() already unmanner.

Here is a small riveted on the knee code, pohjalaisia to compare the performance in sarawakiana conditions. The essence of the question: who is right? Is "the concept of the use of the function" so strong, and so many links to difficult to understand that their application adequately?
October 8th 19 at 00:22
1 answer
October 8th 19 at 00:24
Seen this discussion.

1. links are not cut, to the fortuneteller do not go (besides what You said). Moreover, there are many built-in functions accept as arguments references.

2. This approach allows saving memory and time. Take, functions of some sort, ksrot... having to copy a large array completely it would be very expensive, especially because arrays in PHP are very a lot of places are.

It is also useful sometimes to use the links if you want the method returned multiple values. For example, preg_match returns true/false and you can still get an array of matches. Some come up with their perversions. Imagine that preg_match can be rewritten, it would be possible to receive here such structure: list($is_match, $matches) = preg_match(**), which will significantly complicate the understanding of the function interface.

3. A matter of taste. But it seems to me that the use here links will give a small speed boost.

4. Well... we all use links, because I use native PHP functions. And in my code I use the reference (as it turned out in three places: two methods, one foreach) and yet no animal while using code is not affected.

As for fashion, Yes, programming has its own fashion. The same singletons were once popular, and now they are in disgrace. But in the case of a singleton there are objective reasons. And here I am not objective reasons I see to not use links.
Then in the comments one using the links flashed. I myself do not, but can someone come in handy.

$array= array();
$row = & $array[];
$row = array();
$row[11] = 11;
$row[22] = 22;
- constance.Bei commented on October 8th 19 at 00:27
I understand it is:
$array = array();
$array[] = array();
$index = count( $array ) - 1;
$array[ $index ] = 11;
$array[ $index ] = 22;
To be honest, I always did like in your example. - ethelyn.Wintheiser0 commented on October 8th 19 at 00:30

Find more questions by tags PHP