What are the best practices for integrating a PHP script to parse a URL within a CMS environment?

When integrating a PHP script to parse a URL within a CMS environment, it's important to ensure that the script does not conflict with the existing CMS functionality. One way to do this is by creating a custom plugin or module that hooks into the CMS system to handle URL parsing. This allows you to keep the script separate from the core CMS code and easily manage any updates or changes.

// Custom plugin or module code to parse URL within CMS environment
function parse_url_in_cms() {
    // Get the current URL
    $current_url = $_SERVER['REQUEST_URI'];

    // Parse the URL using PHP's built-in parse_url function
    $parsed_url = parse_url($current_url);

    // Output the parsed URL for testing purposes
    var_dump($parsed_url);
}

// Hook into the CMS system to run the custom function
add_action('init', 'parse_url_in_cms');