Add active class to wp_nav_menu

You wont need that PHP code to style links to the current page in your nav. WordPress adds a class (current-menu-item) by default on links to the current page. But WordPress does not style the link for you. That would be part of the theme. You can add a rule to the theme’s CSS ( typically /wp-content/themes/your_theme/style.css ) to style the link differently. For example :

li.current-menu-item a {
    color: pink;
    // or whatever
}