php - 需要帮助将我的 PHP 应用程序转换为 Coldfusion。谁能帮忙

标签 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);    
}
?>
`

最佳答案

我不太了解 PHP,但我可以推断出一些东西,也可以用 google 搜索一些东西。如果我弄错了,请有人纠正我。

  • > isset() : 虽然不是直接类比,但应该使用 structKeyExists()像这样进行变量检查。 isset() 大部分直接等同于 isDefined() , 但如果可能的话,应该避免 isDefined(),因为它有返回误报的倾向;
  • > $_POST variables与 FORM 范围的变量相同;
  • > stripslashes()取消转义字符串中转义引号的反斜杠;
  • .(点)是 string-concatenation operator , 就像 CFML 中的 &;
  • > fopen()打开一个文件,“w”参数打开它进行写入。所以就像 fileOpen() 的等效用法在 CFML 中。
  • > fwrite()写入所述文件。
  • === false 位检查是否存在文件写入错误,这在 CFML 中没有直接的等效项,所以我想类比是放置一个 try/catch文件操作(无论如何都应该始终执行)。
  • > echo()相当于writeOutput() (或者只是 );
  • > fclose()fileClose()相同.

就是这样:我认为其余部分是不言自明的。

我要说的是,很容易(正确地~)猜测所有这些东西,或者用谷歌搜索。我只是用谷歌搜索“php fopen”、“php dot operator”等(主要是为了获取文档链接)。所以您或许可以自己完成此操作。

关于php - 需要帮助将我的 PHP 应用程序转换为 Coldfusion。谁能帮忙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13637596/

相关文章:

php - Amazon Cloudfront 签名 URL 访问被拒绝问题

php - css 中有没有办法清除所有 font-family + font-size 样式声明?

.net - ColdFusion Web 服务 wsdl 元素

php - mysqli->error : Is it for the last query only, 还是来自查询组的最后一个错误?

php - 这个 ~* 语法在 sql 查询中的作用是什么?

php - 如何在php的另一个页面中调用局部变量

java - Coldfusion 服务器运行良好,但一个站点仅在两分钟左右就出现故障

amazon-s3 - cfdirectory 在 S3 文件夹上的 action=list 时用 + 字符替换空格

coldfusion - 我应该在ColdFusion 9中备份什么?

linux - ColdFusion/Linux multipart/form-data 编码文件上传问题