0

All of the text on my page has to come from a translation file, so my markup is littered with stuff like <?php echo $translation; ?>.

For just one or two calls, it's fine, but when it's all over the page, it makes things awfully verbose. Is there a more concise way to include PHP variables in the markup? I can echo a heredoc, but then it removes all the IDE features for HTML editing like automatic indentation and highlighting.

Is there a way to just do something like {$translation} instead of <?php echo $translation ?>?

2

5 Answers 5

1

You can do

<?=$translation?>

If you have activated short_open_tag in your php.ini

Sign up to request clarification or add additional context in comments.

Comments

0

You could use a template engine like smarty or twig. Smarty for example is supported in an IDE like netbeans.

Comments

0

Use a template language, like twig, it has builtin support for internatiolzation with a simple syntax.

Comments

0

If you want to keep "pure" PHP, you can use <?=$translation?>, or you can use a template engine, like Smarty. There are tons of those, just find one that suits you.

Comments

0

This should help you http://en.wikipedia.org/wiki/Template_engine_%28web%29

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.