Pass variable to a custom label from visualforce page

To know more about custom label Click here
Step 1:
Go to Setup –> App Setup –> Custom Labels.
Step 2:

1

Step 3:
Here for dynamic populate custom label variable value, the custom label value has written like this “My name is {0} {1}”.

2

Step 4:
Now I’ll create an apex controller with two variable to send it custom label.

public class TestCustomLabel{
    public string FirstName{get;set;}
    public string LastName{get;set;}    
     
    public TestCustomLabel(){
        FirstName = 'Biswajeet';
        LastName = 'Samal';
    }
}

Step 5:
Now I’ll create a visualforce page and use the custom label with parameters in it. Here the first parameter “FirstName” is for custom label “{0}” and the second parameter “LastName” is for custom label “{1}”.

<apex:page controller="TestCustomLabel" tabstyle="Account">
    <apex:form>
        <apex:pageblock>
            <apex:outputtext value="{!$Label.TestCustomLabel}">
            <apex:param value="{!FirstName}">
            <apex:param value="{!LastName}">
            </apex:param></apex:param></apex:outputtext>
        </apex:pageblock>
    </apex:form>
</apex:page>

Here is the visualforce page output:

3