我既不是在PHP和ColdFusion之间进行战争,也不是要找出哪种语言比其他语言更好.所以请为这一点提供合理的论据.
我也不确定这类问题是否适合stackoverflow的策略.但在这里
如果您在ColdFusion中验证电子邮件地址test @ testdomain,它会说它是有效的电子邮件地址.但如果您在PHP中测试电子邮件地址,则说它是无效的电子邮件地址.
根据维基百科,这是有效的电子邮件地址.请搜索术语admin @ mailserver1(没有TLD的本地域名)
我的问题是,为什么实施及其背后的原因存在差异.
ColdFusion代码
<cfdump var="#isValid("email","test@testdomain")#">
Run Code Online (Sandbox Code Playgroud)
产量
Yes
Run Code Online (Sandbox Code Playgroud)
PHP代码
<?php
$email = "test@testdomain";
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid";
}
else
{
$emailErr = "valid";
}
echo $emailErr;
?>
Run Code Online (Sandbox Code Playgroud)
产量
Invalid
Run Code Online (Sandbox Code Playgroud) 我有一些代码可以在Railo下运行,但我正试图让这个特定的应用程序在CF10和CF11上工作
这是一个cfWheels应用程序,我BCrypt.class在/miscellaneous/目录中有一个文件.
在我的/events/onapplicationstart.cfm档案中,我有:
application.bCrypt = CreateObject( "java", "BCrypt", "/miscellaneous/" );
Run Code Online (Sandbox Code Playgroud)
这适用于Railo; 但在CF11中我得到了
The java object type is unknown for the CreateObject function.
Verify the type of your object when creating it and try again.
Valid Types are : component | java | webservice | dotnet | com | corba | .NET
The error occurred in /Volumes/Documents/blah/public/events/onapplicationstart.cfm: line 8
Called from /Volumes/Documents/blah/public/wheels/global/cfml.cfm: line 111
Called from /Volumes/Documents/blah/public/wheels/events/onapplicationstart.cfm: line 388
6 :
7 : // BCrypt …Run Code Online (Sandbox Code Playgroud) 抱歉,这个问题短语.我无法找到更好的方式来描述它.但我的问题如下:
我有3个cfc,即settings.cfc,prices.cfc和helpers.cfc.这些cfc扩展了第4个cfc controller.cfc.helper.cfc如下:
<cfcomponent extends="Controller">
<cffunction name="formatCurrency">
<cfset formattedCurrency = 1 />
<cfreturn formattedCurrency>
</cffunction>
<cffunction name="processTemplateVariables">
<cfargument name="templateText" default="defaultText" >
<cfset formatCurrency() />
<cfreturn formattedCurrency >
</cffunction>
</cfcomponent>
Run Code Online (Sandbox Code Playgroud)
settings.cfc有一个setApplicationVariables方法,我们用它来设置应用程序级变量.在这个cfc中,我创建了一个helpers.cfc对象,并将该对象放入应用程序范围.settings.cfc如下:
<cfcomponent extends="Controller">
<cffunction name="setApplicationVariables">
<cfset application.helpers = createObject("component","controllers.Helpers") />
</cffunction>
</cfcomponent>
Run Code Online (Sandbox Code Playgroud)
在应用程序启动时调用settings.cfc,然后创建helpers.cfc的对象并将其放入应用程序范围.
我们在controller.cfc中创建对ProcessTemplateVariables方法的引用,如下所示:
<cfcomponent extends="Wheels">
<cfset getFormattedCurrency = application.helpers.processTemplateVariables >
</cfcomponent>
Run Code Online (Sandbox Code Playgroud)
在prices.cfc中,我们使用此引用来调用function processTemplateVariables它.但它does not call the function formatCurrency从processTemplateVariables内部调用,并抛出错误" variable formatCurrency is undefined ".
但如果我使用它application.helpers.processTemplateVariables(templateText="someText"),它的工作原理.
它也有效,当我使用cfinvoke如下:
<cfinvoke method="processTemplateVariables" component="controllers.helpers" templateText="someText" returnvariable="content">
Run Code Online (Sandbox Code Playgroud)
prices.cfc如下:
<cfcomponent …Run Code Online (Sandbox Code Playgroud) 传奇:
我有使用捆绑的 tomcat CF 的经验。今天我尝试使用 Native tomcat CF。
我能找到的唯一区别是 - 使用本机 tomcat CF,您将 CF 应用程序部署在由 war 文件创建的 Coldfusion实例中,使用捆绑的 tomcat CF,您将 CF 应用程序部署在wwwroot文件夹中。
我试图在网上找出差异,但没有运气。
从这个Charlie 的演讲中,在第 20 页上,我了解到使用 Native tomcat,我们丢失了一些 CGI 变量、CF 会话复制、多个 webroot 支持和 SES URL 支持。但是这篇文章是为CF10写的。对于 CF 2018,这是否仍然适用?
我想知道我们应该使用本机 tomcat CF 还是捆绑 tomcat CF 中的哪一个,以及使用它们的优缺点是什么?
我已在本地计算机上安装了CF10服务器.我们正在从CF9迁移到CF10.我们使用CFWheels框架进行开发.某些项目仍然在CF9上.我想知道,在使用CF10服务器时,有没有办法检查我的代码是否也适用于CF9服务器.谢谢