Coldfusion:
Code: Select all
<cfset astring="todays date is #now()#">Code: Select all
$astring = "todays date is getDate()";Moderator: General Moderators
Code: Select all
<cfset astring="todays date is #now()#">Code: Select all
$astring = "todays date is getDate()";No. When you put data into a double quoted string, PHP first looks for the '$' token (or a combination of braces and the '$' token, i.e. '{$...}') up to the first invalid character for a variable (or the closing bracket if you use it), which consists of non-alphanumeric characters. Then, it replaces that portion of the string with the data in the variable being referred to.paulkd wrote:I'm from a ColdFusion background. I would like to know if it is possible to display the results of a function within a double quoted string. ie not using a dot to concatenate.
Code: Select all
$astring = "todays date is " . getDate();You can't do it like you showed as an example, but you can do it this way, using the concatenation operator . :paulkd wrote:I'm from a ColdFusion background. I would like to know if it is possible to display the results of a function within a double quoted string. ie not using a dot to concatenate.
Coldfusion:PHP:Code: Select all
<cfset astring="todays date is #now()#">I know I can assign a variable and embed it in the double quoted string, but I would like to simply embed the results of the function.Code: Select all
$astring = "todays date is getDate()";
Code: Select all
$astring= "todays date is " . getDate();