Search code examples
drupaldrupal-7

Replacing the token value in the HTML text content


I have a token value

echo variable_get('some_count', '');exit;

This prints 23. But if I try to use the same in the HTML code. I am getting error.

$sone_cnt = '
        <div>

        <p class="sub-heading">How to help , '

        echo variable_get('provider_count', '');

        'number of people</p>

    </div>';

I am new to PHP. Let me know, if anything else is needed to be done here to get this value in the html content.


Solution

  • You have to break out of the string to call the function, and concatenate with the dot

    $sone_cnt = '
        <div>
    
        <p class="sub-heading">How to help , '.
    
        variable_get('provider_count', '').
    
        'number of people</p>
    
        </div>';