从 php 文件中调用并显示文本文件
call and display a text file from a php file
我有以下显示此网页的 php 文件
黑框内的所有内容都来自名为 questions.txt 的文本文件,该文件使用以下代码从 php 文件中调用:
我希望在问题之前调用并显示(以相同的格式,如黑色边框)一些带有图像的介绍性文本和可能的 iframe,如 youtube 视频)。
在下面的代码中,我将其作为注释包含在内 # ...尝试了各种方法,但都没有奏效。
文件需要在"Test your Knowledge"及问题开头上方调用和显示。
<!-- Main
============================================= -->
<section id="code">
<div class="container-fluid" style="text-align:center;">
<p></br></br></br></br></p>
<div class="row">
<div class="col-lg-2 text-left">
<p></br></br></br></br></p>
<?php include 'quiz-sidebar.php'; ?>
</div>
<div class="col-lg-10 text-center">
<h2 class="section-heading" style="color:black;">Test Your Knowledge : <?php include "content/quiz/". $_GET['quiz'] ."/title.txt"; ?></h2>
<p></br></p>
#I want to call and display a txt file here (called introtext.txt), in the same format as below, but just as text
<div style="border-style: solid; border-radius: 5px; border-width: 5px;">
<p></p>
<form method="POST" action="<?php echo "quiz-result.php?quiz=".$_GET['quiz']; ?>">
<?php
$loadedQuestions = readQuestions("content/quiz/". $_GET['quiz'] ."/questions.txt");
displayTheQuestions($loadedQuestions);
?>
<input type="submit" name="submitquiz" value="Submit Quiz"/>
</form>
<p></p>
</div>
<p></br></br></br></br></p>
</div></div>
</div>
</section>
有人可以在我的原始代码中包含一个解释并修复如何调用和显示此文件中所需位置的文本文件(或另一个 php 文件)。
我还想格式化问题的文本,使它们左对齐(已在另一个问题中发布)
我尝试了很多方法,但都没有用:
1. include('questiontrinket.php')(我把它包含在下面)但它只是显示为纯文本而不是呈现文件
<h2 class="section-heading" style="color:black;">Test Your Knowledge : <?php include "content/quiz/". $_GET['quiz'] ."/title.txt"; ?></h2>
<p></br></p>
<?php include('introtext.php') ?>
...没用
2。我也尝试了以下
<?php
echo file_get_contents( "introtext.php" ); // get the contents, and echo it out.
?>
这个也没用
下面的代码适合我
<!-- Main
============================================= -->
<section id="code">
<div class="container-fluid" style="text-align:center;">
<p><br><br><br><br></p>
<div class="row">
<div class="col-lg-2 text-left">
<p><br><br><br><br></p>
<?php include 'quiz-sidebar.php'; ?>
</div>
<div class="col-lg-10 text-center">
<h2 class="section-heading" style="color:black;">Test Your Knowledge : <?php include "content/quiz/". $_GET['quiz'] ."/title.txt"; ?></h2>
<p><br></p>
<!-- I want to call and display a txt file here (called introtext.txt), in the same format as below, but just as text -->
<?php include 'introtext.php'; ?>
<div style="border-style: solid; border-radius: 5px; border-width: 5px;">
<p></p>
<form method="POST" action="<?php echo "quiz-result.php?quiz=".$_GET['quiz']; ?>">
<?php
$loadedQuestions = readQuestions("content/quiz/". $_GET['quiz'] ."/questions.txt");
displayTheQuestions($loadedQuestions);
?>
<input type="submit" name="submitquiz" value="Submit Quiz"/>
</form>
<p></p>
</div>
<p><br><br><br><br></p>
</div>
</div>
</div>
</section>
我有以下显示此网页的 php 文件
我希望在问题之前调用并显示(以相同的格式,如黑色边框)一些带有图像的介绍性文本和可能的 iframe,如 youtube 视频)。
在下面的代码中,我将其作为注释包含在内 # ...尝试了各种方法,但都没有奏效。
文件需要在"Test your Knowledge"及问题开头上方调用和显示。
<!-- Main
============================================= -->
<section id="code">
<div class="container-fluid" style="text-align:center;">
<p></br></br></br></br></p>
<div class="row">
<div class="col-lg-2 text-left">
<p></br></br></br></br></p>
<?php include 'quiz-sidebar.php'; ?>
</div>
<div class="col-lg-10 text-center">
<h2 class="section-heading" style="color:black;">Test Your Knowledge : <?php include "content/quiz/". $_GET['quiz'] ."/title.txt"; ?></h2>
<p></br></p>
#I want to call and display a txt file here (called introtext.txt), in the same format as below, but just as text
<div style="border-style: solid; border-radius: 5px; border-width: 5px;">
<p></p>
<form method="POST" action="<?php echo "quiz-result.php?quiz=".$_GET['quiz']; ?>">
<?php
$loadedQuestions = readQuestions("content/quiz/". $_GET['quiz'] ."/questions.txt");
displayTheQuestions($loadedQuestions);
?>
<input type="submit" name="submitquiz" value="Submit Quiz"/>
</form>
<p></p>
</div>
<p></br></br></br></br></p>
</div></div>
</div>
</section>
有人可以在我的原始代码中包含一个解释并修复如何调用和显示此文件中所需位置的文本文件(或另一个 php 文件)。
我还想格式化问题的文本,使它们左对齐(已在另一个问题中发布)
我尝试了很多方法,但都没有用:
1. include('questiontrinket.php')(我把它包含在下面)但它只是显示为纯文本而不是呈现文件
<h2 class="section-heading" style="color:black;">Test Your Knowledge : <?php include "content/quiz/". $_GET['quiz'] ."/title.txt"; ?></h2>
<p></br></p>
<?php include('introtext.php') ?>
...没用
2。我也尝试了以下
<?php
echo file_get_contents( "introtext.php" ); // get the contents, and echo it out.
?>
这个也没用
下面的代码适合我
<!-- Main
============================================= -->
<section id="code">
<div class="container-fluid" style="text-align:center;">
<p><br><br><br><br></p>
<div class="row">
<div class="col-lg-2 text-left">
<p><br><br><br><br></p>
<?php include 'quiz-sidebar.php'; ?>
</div>
<div class="col-lg-10 text-center">
<h2 class="section-heading" style="color:black;">Test Your Knowledge : <?php include "content/quiz/". $_GET['quiz'] ."/title.txt"; ?></h2>
<p><br></p>
<!-- I want to call and display a txt file here (called introtext.txt), in the same format as below, but just as text -->
<?php include 'introtext.php'; ?>
<div style="border-style: solid; border-radius: 5px; border-width: 5px;">
<p></p>
<form method="POST" action="<?php echo "quiz-result.php?quiz=".$_GET['quiz']; ?>">
<?php
$loadedQuestions = readQuestions("content/quiz/". $_GET['quiz'] ."/questions.txt");
displayTheQuestions($loadedQuestions);
?>
<input type="submit" name="submitquiz" value="Submit Quiz"/>
</form>
<p></p>
</div>
<p><br><br><br><br></p>
</div>
</div>
</div>
</section>