What could be causing a PHP script to only function when directly accessed, but not when called from another HTML page?

The issue could be related to the way the PHP script is being called from the HTML page. Make sure the file paths are correct and that the PHP script is being included or executed properly. Additionally, check for any errors in the PHP script that may be causing it to fail when called from another page.

<?php
// Example of including a PHP script in an HTML page
include 'path/to/your/script.php';
?>