PHP Code in excerpt?

Any PHP code in the post content will get stripped out and not executed. This is a safety issue; you don’t want to allow authors to put in executable code.

To display code in a post, BTW, you would surround it with the <code> tag,

If you want to modify what the excerpt displays, you can use the get_the_excerpt filter, similar to this:

function filter_function_name( $excerpt ) {
  $excerpt .= "Thanks!";
}
add_filter( 'get_the_excerpt', 'filter_function_name' );

Which will add the word “Thanks!” after the excerpt. More examples in the codex here: https://codex.wordpress.org/Plugin_API/Filter_Reference/get_the_excerpt .