Created
March 25, 2014 00:55
Be Careful Using "#" In ColdFusion DE() Expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
Set phone and ext. In reality, these values would be | |
coming out of a data base or input form (over which we | |
do not have control). | |
---> | |
<cfset strPhone = "(123) 456-7890" /> | |
<cfset strExt = "128" /> | |
<!--- | |
Create full phone number complete with base number and | |
line extension. | |
---> | |
<cfset strFullPhone = ( | |
strPhone & | |
IIF( | |
Len( strExt ), | |
DE( " x#strExt#" ), | |
DE( "" ) | |
) | |
) /> | |
<!--- Output new number. ---> | |
#strFullPhone# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
Set phone and ext. In reality, these values would be | |
coming out of a data base or input form (over which we | |
do not have control). | |
---> | |
<cfset strPhone = "(123) 456-7890" /> | |
<cfset strExt = "##128" /> | |
<!--- | |
Create full phone number complete with base number and | |
line extension. | |
---> | |
<cfset strFullPhone = ( | |
strPhone & | |
IIF( | |
Len( strExt ), | |
DE( | |
Replace( | |
" x#strExt#", | |
"##", | |
"####", | |
"all" | |
) | |
), | |
DE( "" ) | |
) | |
) /> | |
<!--- Output new number. ---> | |
#strFullPhone# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment