需要帮助将我的PHP应用程序转换为Coldfusion.谁能帮助

kin*_*tiv 2 php coldfusion

这是当前的PHP,不知道如何开始转换为Coldfusion.我需要在我的coldfusion服务器上发布这个.

<?php
/**
 * Saves POST input as an XML file and returns a JSON response
 */

$xmlString;

if (isset($_POST['xmlString'])){
$filename  = $_POST['xmlFilename'];
$xmlString = stripslashes($_POST['xmlString']);

$newFile = "_data/".$filename.".edit.xml";

//write new data to the file, along with the old data 
$handle = fopen("../".$newFile, "w"); 
if (fwrite($handle, $xmlString) === false) { 
    echo "{error:\"Couldn't write to file.\"}";  
} 
else {
    //echo "{filename:\"".$newFile."\"}";
    echo "success:::$newFile:::$xmlString";
}
    fclose($handle);    
}
?>
`
Run Code Online (Sandbox Code Playgroud)

Ada*_*ron 7

我不太了解PHP,但我可以推断出东西,我可以谷歌的东西.如果我弄错了,有人可以纠正我.

  • isset():虽然不是直接类比,但应该使用structKeyExists()来执行这样的变量检查.isset()大部分直接等同于isDefined(),但是isDefined()如果可能的话,应该避免由于其返回误报的倾向;
  • $ _POST变量与FORM范围的变量相同;
  • stripslashes() unescapes在字符串中转义引号的反斜杠;
  • .(dot)是字符串连接运算符,就像&在CFML中一样;
  • fopen()打开一个文件,"w"参数打开它进行写入.就像CFML 中fileOpen()的等效用法一样.
  • fwrite()写入所述文件.
  • === false 位检查是否存在文件写入错误,其中没有直接等效的CFML,所以我猜这个类比就是在文件操作中放置一个try/catch(无论如何应该总是这样做).
  • echo()相当于writeOutput()(或只是<cfoutput>);
  • fclose()fileClose()相同.

这是关于它的:我认为其余部分是不言自明的.

我要说的一件事是,很容易(正确地)猜测所有这些东西,或谷歌它.我只是用Google搜索"php fopen","php dot operator"等(主要是为了获取文档的链接).所以你也许可以自己做到这一点.