How to access a variable name in ColdFusion that c

2019-07-15 10:42发布

问题:

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"]