我想呼應一個頁面特定的文本字符串。當標籤在頁面上時,我對此沒有任何問題,但是在包含內容時,我遇到了問題。例如:回聲從一個包含的數據字符串
的index.php
<?php
$StringData1 = "String of page specific text on page echoes.";
include("IncludeHeader.php");
?>
<html>
<head></head>
<body>
<p>Start Echo Test</p>
<p>Echo Test For StringData1: <?php echo "$StringData1"; ?></p>
<p><?php include("IncludeFile.php");?></p>
<p>Stop Echo Test</p>
</body>
</html>
IncludeHeader.php
// Many Global Variables called from various CSV Files. To be exact $StrindData2 is actually $StringData2[1] from an array. The array is of a row of CSV fields
$StringData2 = "String of page specific text in include won't echo.";
IncludeFile.php
Echo Test For Included StringData2: <?php echo "$StringData2"; ?>
當index.php的運行的輸出爲:
<html>
<head></head>
<body>
<p>Start Echo Test</p>
<p>Echo Test For StringData1: String of page specific text on page echoes.</p>
<p>Echo Test For Included StringData2: </p>
<p>Stop Echo Test</p>
</body>
</html>
從這個例子中,我怎麼能得到$ StringData2從包含內部回顯?
感謝您的任何幫助。
另外:你不需要引用變量! 'echo $ StringData2'工作正常。 – deceze 2012-03-20 05:42:00
查看http://stackoverflow.com/questions/3558336/pass-variable-to-string-in-include-file-php – 2012-03-20 05:42:41
另外,激活錯誤報告,讓我們知道,如果你看到任何錯誤:'error_reporting(E_ALL) ; ini_set('display_errors',true);' – deceze 2012-03-20 05:43:14