lundi 12 janvier 2015

PHP convert echo into a variable for re-use

I know this is basic PHP but I can't find an answer to my conundrum.


I have the following IF statement:



<?php if ( in_category(7)) { echo 'f' } elseif ( in_category(6)) { echo 'e' } elseif ( in_category(3)) { echo 'b' } elseif ( in_category(1)) { echo 'a' } elseif ( in_category(5)) { echo 'd' } elseif ( in_category(8)) { echo 'g' } elseif ( in_category(4)) { echo 'c' } ?>


Where I currently echo a letter, I would instead like to store that echo in a variable so I can echo that variable and re-use within the rest of my page.


How would I re-write the above to store the result as a variable?


Aucun commentaire:

Enregistrer un commentaire