dongxiaowei_1234 2015-12-10 12:33 采纳率: 0%
浏览 34

需要帮助回显与另一个回声链接的包含

I have a 3 php files where i am trying to echo an include from a page.php to template.php but the include is another php file (Slideshow.php) it works but is positioned in the wrong place

The result needs to be like this: http://st-margarets-barking.org.uk/SchoolDay.php

the codes i have are:

template.php:

<body>

<?php echo $slideshow; ?>

</body>

page.php:

<?php
$content = "content";
$slideshow = include("Slideshow.php");
$template = "template.php";
require($template);
?>

Slideshow.php:

<?php echo "<img src='Images/slideshow-frame.png' style='position:relative; top:-20px;'>
<div class='cycle-slideshow slideshow-width' data-cycle-speed='500' data-cycle-timeout='5000'>
<img src=Images/slides/041214%20Assembly%20(5).png>
<img src=Images/slides/Evacuation-Day-001.png>
<img src=Images/slides/Trewern-002.png>
<img src=Images/slides/church-silhouette.png>
<img src=Images/slides/Evacuation-Day-003.png>
</div>";
?>

The result is this: http://st-margarets-barking.org.uk/SchoolDay0.php

I have tried:

page.php

$slideshow = "<?php include('Slideshow.php');";

However this shows a server error

I can do this:

template.php:

<?php include("Slideshow.php"); ?>

This works, but then I have to create more template.php as well as more Slideshows.php, this is not what I want to do

the point of this is to have different slideshow.php files so I can change the slideshow in the page.php, then the template.php will echo the slideshow and all other content on the page.php, this will save me time of having to change the slideshow images on each page.php

can anyone show me what I am doing wrong?

  • 写回答

1条回答 默认 最新

  • dpgu5074 2015-12-10 13:03
    关注

    If you are trying to display the content of Slideshow.php inside template.php, you have to change it like this:

    <?php 
    function images() {
        $str =  "<img src='Images/slideshow-frame.png' style='position:relative; top:-20px;'>
        <div class='cycle-slideshow slideshow-width' data-cycle-speed='500' data-cycle-timeout='5000'>
        <img src=Images/slides/041214%20Assembly%20(5).png>
        <img src=Images/slides/Evacuation-Day-001.png>
        <img src=Images/slides/Trewern-002.png>
        <img src=Images/slides/church-silhouette.png>
        <img src=Images/slides/Evacuation-Day-003.png>
        </div>";
        return $str;
    }
    ?>
    

    Then call the method inside page.php like:

    include("Slideshow.php");    
    $slideshow = images();
    
    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来