When looking through WordPress snippets/tutorials/plugins I often see add_action() and add_filter() being placed before the function is declared:

add_action( 'publish_post', 'email_friends' );

function email_friends( $post_ID ) {
   $friends = 'bob@example.org, susie@example.org';
   mail( $friends, "sally's blog updated" , 'I just put something on my blog: http://blog.example.com' );
   return $post_ID;
}


From a logic standpoint this just doesn't make sense to me.  Why would you place the function after it is called in your code?  This is usually how I would handle the same situation:

function email_friends( $post_ID )  {
   $friends = 'bob@example.org, susie@example.org';
   mail( $friends, "sally's blog updated" , 'I just put something on my blog: http://blog.example.com' );
   return $post_ID;
}

add_action( 'publish_post', 'email_friends' );


I know both scenarios work, but is there a specific advantage to one or the other?  About 90% of the time I see the first scenario being used, so that leads me to believe there is a benefit to this in some way.


Question: How can I prevent a faucet retaining nut from freezing to a steel washer?
Answer: Anti-Seize Lubricating Compound 

Make sure it's waterproof



Pipe Dope

Make sure it's Anti-seize



I do not specifically recommend nor endorse either product, they are only used as examples.