douchengchen7959 2013-11-07 16:55
浏览 29
已采纳

PHP包括在WAMP上解释为罚款但在远程服务器上被忽略

I have a static HTML header and footer included site wide via php include (php/navigation) and (php/footer.php) respectively.

The page interprets and includes all the of the above on WAMP with no errors (with either include or require) but when moved to my (LAMP) server the header and footer files are ignored (if i use require -- page displays nothing, so I know there is an error but I haven't been able to track it down)

other php includes in between the header and footer includes are read and displayed correctly and if i cut the the navigation.php and add it in place of the include it renders correctly -- but obviously i would rather avoid this approach.

  • 写回答

1条回答 默认 最新

  • duano3557 2013-11-07 17:01
    关注

    Try using the full file path. At the top of your file put this:

    define('ROOT', __DIR__ . '/', TRUE);
    

    Then when you want to call a file use:

    include ROOT . 'path/to/file.php';
    

    See if that helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?