php - Smarty: how to evaluate string as a variable -
   variable assigned to my template {$ testVariable_123}, where 123 auto is generated and also in the form of the {$ autoValue template} Work assigned}   So in my template I want to get the value of variable above   So if I print {$ anotherValue} instead of the price, then I get string 'testVariable_123'   Any help appreciated ...  
  {Assign var = "Other value" value = "testVariable_" | Cat: $ autoValue}  
   The problem is, There was no way to do this well.   Perhaps you will consider some changes in your application design?    Here's how to work:    Mostly, the problem is that clever one closing bracket} or $ variable will not be ignored , Even if it's in the middle of the string. Running with \ N does not work   You try.   It is clever as "end" Consider the statement:   and this $ Although it will evaluate the test variable, it should be escaped.  ) I stumbled upon whatever problem I tried. If you find a better way Please make sure you share it here :)  {$ testVariable_123}  
 You can call  {/ P> 
 Whatever looks good does not work and is not an option. This work is ugly.   
  # File.php: $ smarty- & gt; Assign ("Autwale", 123); $ Smarty- & gt; Assign ("testVariable_123", "foo"); // Option 1 $ smerty-> Assign ("Other value", "{\ $ testVariable_123}"); // Option 2 $ Smarty-> Assign ("RB", '}'); // hack, to get the correct bracket} Pars it wisely // option 3 $ smartri-> Assign ("mask", '{$ testVariable_% s}'); // full string_format php # directly passed "mask" directly from file.tpl 1) PHP uses $ anotherValue: Plain: {$ anotherValue} Evaled: {eval var = $ anotherValue} 2) String only on clever: {Assigned var = "yetAnotherValue" value = $ autoValue | Plain_format: "{$ $} $ trueVerable_% s $ rb"} plain: {$ yetAnotherValue} Evaled: {eval var = $ yetAnotherValue} 3) String Build using mask from php: {allocated var = "enoughOfValue" value = $ autoValue | Plain_format: $ mask} Plain: {$ enoughOfValue} Evaled: {eval var = $ enoughOfValue}   
  {allocated var = "yetAnotherValue" value = "{\ $ testVariable_ $ autoValue}"}   
  will not pay attention to allocated = "yetAnotherValue" value = "{\ $ testVariable_ $ AutoValue}  
 So we will end up with  {\ 123 : value (
Comments
Post a Comment