PHP confusion in WP Hook

This is the code in the core WP File →

echo apply_filters( 'admin_footer_text', '<span id="footer-thankyou">' . $text . '</span>' );

I got this snippet:

function wpplugin_custom_admin_footer( $footer ) {

  $new_footer = str_replace( '.</span>', __(' and <a href="https://.........com">ZG</a>.</span>', 'wpplugin' ), $footer);
  return $new_footer;

}
add_filter( 'admin_footer_text', 'wpplugin_custom_admin_footer', 10, 1 );

https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_string_str_replace

what is $footer?

My confusion is how is $footer able to take care of the whole string that is actually in core WP, and in which we want to make a final replacement.

Hi @codeispoetry,

Maybe you should do a var_dump on the $footer to check it out

Hey there, thanks for replying.
No troubleshooting issues but understanding logic issues.

Maybe this discussion may help →

function wpplugin_add_settings_link( $links ) {
    $settings_link = '<a href="admin.php?page=wpplugin">' . __( 'Settings', 'wpplugin' ) . '</a>';
    array_push( $links, $settings_link );
  	return $links;
}

Logically(PHP programming logic) what is happening here?
$link connection to $settings_link