2013-05-21 49 views
1

我正在製作一個textEditor網站,僅僅爲了我的樂趣,我得到了大部分我將要做的事情。但現在,我想知道我在使用_GET方法在php中傳輸數據時遇到問題,如果它是&lt;(<),將不會寫入我的文件。由於某些奇怪的原因,它必須是<。轉讓它時,有沒有一種簡單的方法可以覆蓋它?我可以找到某種方式,但想知道是否有一種簡單的方法。_GET方法php

編輯器文件:

<html> 
<head> 
<title>Web Editor</title> 
<link href="controller.css" rel="stylesheet"/> 
<script type="text/javascript" src="script/editor.js"></script> 
</head> 
<body> 
<div class="platform"> 
<div class="head"><div class="file"><p>File: <div id="file">hello.html</div></p></div></div> 
<div class="hotbar"><img src="images/save.png" class="hotbarImage" onClick="save()" /> 

</div> 
<div class="editor"><div contenteditable="true" style="height:100%; overflow:scroll;" id="editPad" ></div></div> 
</div> 




</body> 
</html> 

php文件:

<?php 
$dir = $_GET['dir']; 
$data = $_GET['data']; 

$f = fopen($dir,"w"); 
fwrite($f,$data); 
fclose($f); 
?> 

SAVE js文件:

function save() { 
    var dir = document.getElementById("file").innerHTML; 
    var data = document.getElementById("editPad").innerHTML; 
    window.location = "save.php?dir="+dir+"&data="+data; 
} 

這不是完整的正義事業,我今天開始,但正在研究一些基本功能。

+2

得到的是一個壞適合這種使用情況...使用POST – Orangepill

+0

是POST在這種情況下,最好的一個?我真的不記得自從我使用POST和GET以來有一段時間了。 – Matthew

+2

['urlencode'](http://php.net/manual/en/function.urlencode.php)和['urldecode'](http://www.php.net/manual/en/function.urldecode。 PHP)可能會有幫助,但我們必須知道更多以提供具體答案。 –

回答

1

html_entity_decode('&lt;')