How to access a variable name in ColdFusion that contains a special character

笑着哭i 提交于 2019-12-11 02:15:00

问题


For example I have the following bit of code:

<cfhttp url="FileURL" method="get" result="HTTPResult" timeout="5" />

And I want to do this:

<cfoutput>
    #HTTPResult.ResponseHeader.content-type#
</cfoutput>

However ColdFusion will see the dash - as an operator and try to subtract variables "HTTPResult.ResponseHeader.content" from "type", and neither exists. Is there a direct way to access the "content-type" variable or do I need to jump through hoops to fetch it out of the header variable?


回答1:


HTTPResult.ResponseHeader["content-type"]


来源:https://stackoverflow.com/questions/6312226/how-to-access-a-variable-name-in-coldfusion-that-contains-a-special-character

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!