首先這是我的PHP代碼。我試圖將此代碼作爲文本輸出。不知道我該怎麼做。與HTML我們可以做\"
插入PHP內,但我如何得到這樣做就像我的代碼?獲得PHP作爲文本輸出
<?php
$stringData = "
// Start here
<?php
$width = $_GET['width'];
$heigh = $_GET['height'];
echo 'Hello';
?>
// End here
";
?>
我有顯着的,我想它作爲文本輸出部分,但是當我把它像網頁上我得到語法錯誤不知道爲什麼。這裏下面
編輯#2
是我完整的代碼和我解釋我的代碼是如何工作是爲了什麼。 我的代碼是創建頁面,並把東西創造
<form method="post">
<label>Page Name:</label><br>
<input type='text' name='filename' placeholder='page name'>
<label>Folders</label>
<select name="thisfolder">
<option value="">Default</option>
<option value="Folder1">Folder1</option>
<option value="Folder2">Folder2</option>
<option value="Folder3">Folder3</option>
</select><br><br>
<label>content</label><br>
<input type='text' name='strin' placeholder='content of created page'>
<input type='submit' value='Add Feed'>
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// the name of the file to create
$filename=$_POST['filename'];
// the name of the file to be in page created
$strin=$_POST['strin'];
// the name of the folder to put $filename in
$thisFolder = $_POST['thisfolder'];
// make sure #thisFolder of actually a folder
if (!is_dir(__DIR__.'/'.$thisFolder)) {
// if not, we need to make a new folder
mkdir(__DIR__.'/'.$thisFolder);
}
// . . . /[folder name]/page[file name].php
$myFile = __DIR__.'/'.$thisFolder. "/page" .$filename.".php";
$fh = fopen($myFile, 'w');
$stringData = "
<?php
$width = $_GET['width'];
$heigh = $_GET['height'];
echo '';
?>
";
fwrite($fh, $stringData);
fclose($fh);
}
?>
什麼,我試圖做的是頁面內,通過在PHP代碼裏面$stringData
到將要創建
你不呼應的變量在那裏,但如果你沒有'的eval($ StringData是) ;' – AbraCadaver