Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:48:42+00:00 2026-06-06T14:48:42+00:00

How to assign a local template variable with a string concatenated just like below:

  • 0

How to assign a local template variable with a string concatenated just like below:

{$yes_src=const1.'yes'.const2}

to be used below in the code in the manner {$yes_src}.

By the way I am looking for a job as PHP developer 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:48:43+00:00Added an answer on June 6, 2026 at 2:48 pm

    The way you are doing it is call the “short form” of assign, you just need to use the correct quoting mechanism:

     {$yes_src="`$const1`yes`$const2`"}
    

    Use assign:

    {assign var="yes_src" val="`$const1`yes`$const2`"}
    

    Use cat:

    {$const1|cat:"yes"}{$const2}
    

    You can also simply put the variables next to one another without assigning it to a variable:

    {$const1}yes{$const2}
    

    … no variable needed.

    A note If you find yourself using assign more than rarely, you might have a misconception about the ideas of separating logic from presentation. Usually, concatenation and other variable work would be accomplished in PHP before the template is ever involved. The template’s role is to just display the data, you should avoid creating or altering the data in the template.

    Documentation

    • Smarty quotes – http://www.smarty.net/docs/en/language.syntax.quotes.tpl
    • Smarty assign – http://www.smarty.net/docs/en/language.function.assign.tpl
    • Smarty cat – http://www.smarty.net/docsv2/en/language.modifier.cat
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Local variable assign versus direct assign; properties and memory Which way is
Can I assign a pointer to an integer variable? Like the following. int *pointer;
Is it possible to assign a local variable a value whose scope is outside
I have successfully scheduled local notifications in my app using the code below: Class
Can I assign the result of an SQL select command to a local variable
How can I assign Clipboard text to a local variable using XPCOM. I need
In python, if I create a local variable _ (underscore) and assign it to
Is it possible in javascript to assign an alias/reference to a local var someway?
//assign variables string measurementIn; //read in file in array string[] lines = File.ReadAllLines(../../convert.txt); //ask
To assign specific value to 1D array I'm using LINQ like so: int[] nums

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.