Is it best practice to use the ID instead of the nickname in a link in PHP scripts?

It is generally best practice to use the ID instead of the nickname in a link in PHP scripts. Nicknames can be changed by users, leading to broken links or potential security vulnerabilities if not properly sanitized. Using IDs ensures a unique identifier for each resource and reduces the risk of errors.

// Using ID instead of nickname in a link
$id = 123; // Example ID
echo "<a href='profile.php?id=$id'>View Profile</a>";