doushe2513 2015-04-06 09:06
浏览 71

在html中调用外部php文件无法正常工作

I have an html file called index.html where I want to add external php file to run it as my "header". I cut the code which contains logo and navigation menu and added it to a file named header.php.

I've used this code: <?php include 'header.php';?> after my <body id="page1"> div but what loads is the rest of the pages without the navigation menu that is on header.php. I've also tried using ajax as someone else mentioned in another post but this doesn't work too.

Code before changes

Code after changes

  • 写回答

5条回答 默认 最新

  • douxun4173 2015-04-06 09:20
    关注

    The problem is: you are trying to include a PHP file in an HTML file. An HTML file cannot process a PHP file. Rename your index.html file to index.php'. And then view it using thehttp://protocol rather than thefile://` protocol.

    评论

报告相同问题?

悬赏问题

  • ¥15 MapReduce实现倒排索引失败
  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题