How do I use PHP code in a block?
PHP filter is a core module in Drupal 7 but in Drupal 8 it is removed because of some security reason but still you can use this module PHP.

Note: Enabling this module can cause security and performance issues as it allows users to execute PHP code on your site.