php - echoing webpage title from the defined list -
i got way display custom page titles using include fuction.
header:
<title><?php echo $pagetitle ?></title>
include:
<?php $pagetitle = "pets:"; include '../header.php'; ?>
so handle titles easier i'd name come predefined list:
<?php define('animal', 'dog'); ?>
how add 'animal' $pagetitle = "pets:"?
to answer question:
<?php $pagetitle = "pets:"; define("animal", "dog"); $pagetitle .= animal; echo $pagetitle; // yields "pets:dog"; ?>
but fair, arrays, not constants in case.
something this:
<?php $pagetitle = "pets:"; $animals = array('dog', 'cat', 'bird', 'super cow'); echo $pagetitle . $animals[0]; // yields "pets:dog"; ?>
Comments
Post a Comment