The value of the definition of such a function in wordpress "function & get_post"

I have been working on wordpress research recently and am trying to figure out how the request mechanism is handled.
I came across a function definition like this
function &get_post(&$post, $output = OBJECT, $filter = 'raw')
I have not seen anything like this before and am not sure that the ampersand (&) has to do something with the address. (Mentally thinking about using ampersand (&)).
I am naive about it and spare me if its something easy.
Can someone give their thoughts on this. This will help me move forward. I tried to find it through Google and the documentation, but could not find a solution.
Thanks

+4
source share
1 answer

The first & in the function declaration calls PHP returns the link . & on $post makes a change to the actual variable that you pass to the function.

I really don’t understand why one of these (reference declarations) is used. It seems to me that this is an incorrect optimization attempt on Wordpress, or, most likely, compatibility with PHP 4. I think you can just ignore ampersands for your purposes.

+4
source

Source: https://habr.com/ru/post/1447866/


All Articles