I am working on wordpress research recently and trying to dig how the query mechanism is handled.
I came across a function definition like thisfunction &get_post(&$post, $output = OBJECT, $filter = 'raw')
I have not seen anything similar before and not sure if the ampersand(&) has to do something with the address.(Thinking traditionally the use of ampersand(&) ).
I am naive in this and spare me if its something easy.
Can anyone give their thoughts on this.It would help me in moving forward.Tried to find it through google and documentation but did not get find a solution.
Thanks
The first &
on the function declaration causes PHP to return a reference. The &
on $post
makes changes to the actual variable that you pass into the function.
It's actually unclear to me why either of these (the reference declarations) are used. It seems to me to be an incorrect attempt at optimization on Wordpress' part, or it is more likely for compatibility with PHP 4. I think you can just ignore the ampersands for your purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With