How to use Php code in Views page contextual filter with dynamic URL i.e using %?
I'd highly recommend not using PHP code to do this; tying PHP code to configuration can be error-prone and it won't exist in Drupal 8's Views. 

Rather, you can use the solution in Drupal 7 views contextual filters taxonomy name where you can use the Validator, Taxonomy Term, instead of PHP Code, with the Term name converted to Term ID filter.