In your fucntions.php file or a PHP function in general it is recommended to assign the returned permalink to a variable from get_the_permalink() or get_permalink() functions. You need to use the $post parameter to pass the post ID.
Example:
global $post;
$post_URL = get_the_permalink($post->ID);