0

I want to echo my var.

For example:

<?php
  echo $MONTH09;  // Return September
?>

I need to bulid it like this:

<?php
  echo $$."MONTH".date('m');
?>

But it does not work.

thanks for your help.

4
  • Is the variable variable ($$) intentional? Also, PHP does not support . as object notation, so is the . meant for concatenating a string? Commented Sep 3, 2013 at 13:34
  • Is there a reason you're not using an array to store the month names? Commented Sep 3, 2013 at 13:35
  • Cause it's a multilingual system. Commented Sep 3, 2013 at 13:36
  • How does that explain why you can’t use an array instead of variables with an index in their name? Commented Sep 3, 2013 at 14:26

1 Answer 1

2

Try with:

echo ${'MONTH' . date('m')};

But better way to print month is:

echo date('F');
Sign up to request clarification or add additional context in comments.

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.