在PHP文件中添加一个PHP文件

时间:2019-05-20 07:41:08

标签: php html

我正在尝试在php文件中添加一个php文件,但无法正常工作。

<?php
echo '

<p><a href="/Confusing_English/A_Lot_Of_Many.html"><strong> A Lot Of & Many </strong></a></p>

<p><a href="/Confusing_English/Already.html"><strong> Already </strong></a></p>


 <?php include 'Include/adsense.php'; ?>    

  ';
?>

3 个答案:

答案 0 :(得分:1)

您已在字符串引号('not executable string')中编写了所有内容,因此解释程序将其读取为字符串,而不是可执行代码。

也无需使用PHP echo纯HTML。

执行以下操作:

<p><a href="/Confusing_English/A_Lot_Of_Many.html"><strong> A Lot Of & Many </strong></a></p>    
<p><a href="/Confusing_English/Already.html"><strong> Already </strong></a></p>    

<?php include 'Include/adsense.php'; ?> 

说明

有一个小的代码示例:

<?php // start tag

echo 'This is not executable'; // it will just show on your screen "This is not executable"

include 'Include/adsense.php'; // let's consider is as command, PHP parser will read it as a single command, in this case it tells to include given file

echo 'Not executable either'; // part inside quotes is not executable, so it will output on the screen "Not executable either"

?> // end tag

我认为您应该阅读一些有关PHP基础的知识。下面的链接(w3schools在某些情况下不是很好,但是对于基本知识我认为还可以)。


手册

PHP Include

PHP Basics

答案 1 :(得分:0)

您将<?php放入PHP已经输出的字符串中,

只需将代码更改为

<?php
   echo '
   <p><a href="/Confusing_English/A_Lot_Of_Many.html"><strong> A Lot Of & Many </strong></a></p>

   <p><a href="/Confusing_English/Already.html"><strong> Already </strong></a></p>
   ';

    include 'Include/adsense.php';
?>

答案 2 :(得分:-1)

尝试一下:

<?php

echo '<p><a href="/Confusing_English/A_Lot_Of_Many.html"><strong> A Lot Of & Many </strong></a></p><p><a href="/Confusing_English/Already.html"><strong> Already </strong></a></p>';
include 'Include/adsense.php';

?>