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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据