What are the best practices for hiding or displaying links based on the type of access (local or internet) in PHP?

To hide or display links based on the type of access (local or internet) in PHP, you can check the IP address of the user accessing the page. If the IP address is within a specific range, you can display the links, otherwise, you can hide them.

<?php
// Get the user's IP address
$user_ip = $_SERVER['REMOTE_ADDR'];

// Check if the user is accessing the page from a local network
if (substr($user_ip, 0, 7) == '192.168') {
    // Display links for local access
    echo '<a href="#">Local Link 1</a>';
    echo '<a href="#">Local Link 2</a>';
} else {
    // Display links for internet access
    echo '<a href="#">Internet Link 1</a>';
    echo '<a href="#">Internet Link 2</a>';
}
?>