PHP calling to a constant using text + variable -


i'm creating application mother can play quizmaster. since have play on of canditates, cannot know answers + questions.

my solution was, creating constant page fill out without breaking code. display of page question spoiler tag containing answer.

now comes question, i'm not sure if possible, how implement this? thought giving id page (through url) can change constants question_1, question_2 etc. way can add many questions want without me having make more pages.

my page code this:

$page = $_get['id']; 

            <div class="spoiler">                  <input type="button" onclick="showspoiler(this);" value="show/hide" />                  <div class="inner" style="display:none;">                     <?php echo answer_1; ?>                 </div>              </div> 

ofcourse, question . $page not work. (use of undefined constant question). possible create application in way described?

my bad, found solution:

just use

$constant_name = 'question' . $page; echo constant($constant_name); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -