I'm curious as to why the following does not produce the same results.
Inside smarty template:
{php}
$str = "'" . addcslashes(str_replace(',', '.', var_export($p_data[0], true)), "'") . "'";
$GLOBALS['page']->assign("str", $str);
{/php}
Output value of smarty variable<br>
{$str}
<br><br>
Output value of variable with embedded php<br>
{php} echo $str; {/php}
<br><br>
Direct output<br>
'array ( \'pID\' => \'1\'. \'fName\' => \'John\'. \'lName\' => \'Doe\'. )'
Which displays:
Output value of smarty variable
'array ( \'pID\' => \'1\'. \'fName\' => \'John\'. \'lName\' => \'Doe\'. )'
Output value of variable with embedded php
'array ( \'pID\' => \'1\'. \'fName\' => \'John\'. \'lName\' => \'Doe\'. )'
Direct output
'array ( \'pID\' => \'1\'. \'fName\' => \'John\'. \'lName\' => \'Doe\'. )'
However, while this works (outputs the same as above except for the first and last single quote and with the others no longer escaped),
<select name="hmp" id="hmp"
onchange="display_stuff('array ( \'pID\' => \'1\'. \'fName\' => \'John\'. \'lName\' => \'Doe\'. )')">
the following alternatives do not (each of them displays nothing)
<select name="hmp" id="hmp"
onchange="display_stuff({php} echo $str;>{/php})"
<select name="hmp" id="hmp"
nchange="display_stuff({$str})">
So, what am I missing here?