How can I change the tag dynamically in php based on the URL values</a></h1> </div> <div class="grid fw-wrap pb8 mb16 bb bc-black-075"> <div class="grid--cell ws-nowrap mr16 mb8" title="2016-01-12 19:07:53Z"> <span class="fc-light mr2">Asked</span> <time itemprop="dateCreated" datetime="2009-01-14T01:20:12.060" class="fromnow">Jan 14 '09 at 01:20</time> </div> <div class="grid--cell ws-nowrap mr16 mb8"> <span class="fc-light mr2">Active</span> <time class="fromnow" title="2009-01-14T02:46:25.443" datetime="2009-01-14T02:46:25.443">Jan 14 '09 at 02:46</a> </div> <div class="grid--cell ws-nowrap mb8" title="Viewed 4,931 times"> <span class="fc-light mr2">Viewed</span> 4,931 times </div> </div> <div id="mainbar" role="main" aria-label="questions and answers"> <div id="question" class="question" data-questionid="441565" data-ownerid="43980" data-score="2"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="441565"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="2">2</div> <button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4"> <svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 00-2 2v14l5-4 5 4V3a2 2 0 00-2-2H6zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77z"></path></svg> <div class="js-bookmark-count mt4" data-value="0">0</div> </button> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>I want the title page to be changed so that a crawler can see it.</p> <p>The URL is of the format: public.sample.com/account/Disney</p> <p>I load a standard, global header include file using require()</p> <p>That's where the current default tags are defined.</p> <p>IF the URL is public.sample.com/account/Disney, I would like the tag to read, instead:</p> <p>This is an account profile for Disney</p> <p>I believe something would need to be written in this global header file, but not sure what.</p> <p>Thanks.</p></div> <div class="mt24 mb12"> <div class="post-taglist grid gs4 gsy fd-column"> <div class="grid ps-relative"> <a href="../../questions/tagged/php" class="post-tag js-gps-track" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/meta-title" class="post-tag js-gps-track" title="show questions tagged 'meta-title'" rel="tag">meta-title</a> <a href="../../questions/tagged/html-title" class="post-tag js-gps-track" title="show questions tagged 'html-title'" rel="tag">html-title</a> </div> </div> </div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="edited Jan 14 '09 at 02:31">edited Jan 14 '09 at 02:31</time> <a href="../../users/40161/davgarcia" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/40161.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="DavGarcia" /> </a> <div class="s-user-card--info"> <a href="../../users/40161/davgarcia" class="s-user-card--link">DavGarcia</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">18,540</li> <li class="s-award-bling s-award-bling__gold" title="14 gold badges">14</li> <li class="s-award-bling s-award-bling__silver" title="58 silver badges">58</li> <li class="s-award-bling s-award-bling__bronze" title="96 bronze badges">96</li> </ul> </div> </div> </div> <div class="post-signature owner grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 14 '09 at 01:20">asked Jan 14 '09 at 01:20</time> <a href="../../users/43980/afg" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/43980.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="AFG" /> </a> <div class="s-user-card--info"> <a href="../../users/43980/afg" class="s-user-card--link">AFG</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,675</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="22 silver badges">22</li> <li class="s-award-bling s-award-bling__bronze" title="23 bronze badges">23</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="answers-subheader grid ai-center mb8"> <div class="grid--cell fl1"> <h2 class="mb0" data-answercount="9">2 Answers<span style="display:none;" itemprop="answerCount">2</span></h2> </div> </div> </div> <a name="441610"></a> <div id="answer-441610" class="answer " data-answerid="441610" data-ownerid="50453" data-score="6" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="441610"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="6">6</div> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>Super simple example to get you started.</p> <pre><code><title><?php if ( preg_match('/([^\/]+)\/([^\/]+)$/', $_SERVER['PHP_SELF'], $matches) ) { list($dummy, $profileType, $profileName) = $matches; $safeProfileType = htmlentities($profileType); $safeProfileName = htmlentities ($profileName); echo "This is an $safeProfileType profile for $safeProfileName"; } else { echo "Unknown profile!"; } ?></title> </code></pre> <p>Edited per Allain Lalonde comment. (Hope this is what he meant)</p></div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="user-info "> <div class="user-action-time">edited <span title="2009-01-14T02:46:25.443" class="relativetime">Jan 14 '09 at 02:46</span></div> <div class="user-gravatar32"></div> <div class="user-details" itemprop="author" itemscope="" itemtype="http://schema.org/Person"> <span class="d-none" itemprop="name">Beau Simensen</span> <div class="-flair"></div> </div> </div> </div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="answered Jan 14 '09 at 01:40">answered Jan 14 '09 at 01:40</time> <a href="../../users/50453/beau-simensen" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/50453.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Beau Simensen" /> </a> <div class="s-user-card--info"> <a href="../../users/50453/beau-simensen" class="s-user-card--link">Beau Simensen</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">4,558</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="38 silver badges">38</li> <li class="s-award-bling s-award-bling__bronze" title="55 bronze badges">55</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> <div id="comments-441610" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="441610" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-263671" class="comment js-comment " data-comment-id="263671" data-comment-owner-id="2443" data-comment-score="1"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="warm">1</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment263671_441610"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Some care must be taken when doing this since it's possible to craft a URL that could be used for Cross Site Scripting. $profileName should be escaped before it's displayed.</span> – <a href="../../users/2443/allain-lalonde" title="91,574 reputation" class="comment-user ">Allain Lalonde</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/441565/how-can-i-change-the-title-tag-dynamically-in-php-based-on-the-url-values#comment263671_441610"><span title="2009-01-14T02:25:07.360 License: CC BY-SA 2.5" class="relativetime-clean">Jan 14 '09 at 02:25</span></a></span> </div> </div> </li> <li id="comment-263721" class="comment js-comment " data-comment-id="263721" data-comment-owner-id="50453" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment263721_441610"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Added htmlentities for the two pieces of data that came from the URL.</span> – <a href="../../users/50453/beau-simensen" title="4,558 reputation" class="comment-user ">Beau Simensen</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/441565/how-can-i-change-the-title-tag-dynamically-in-php-based-on-the-url-values#comment263721_441610"><span title="2009-01-14T02:56:04.223 License: CC BY-SA 2.5" class="relativetime-clean">Jan 14 '09 at 02:56</span></a></span> </div> </div> </li> </ul> </div> </div> </div> </div> <a name="441573"></a> <div id="answer-441573" class="answer " data-answerid="441573" data-ownerid="2847" data-score="1" itemprop="suggestedAnswer" itemscope="" itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="441573"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="1">1</div> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>im not sure exactly what you are looking for here, but to have a dynamic title you can do:</p> <pre><code><title><?php echo $theDynamicTitle; ?></title> </code></pre></div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="answered Jan 14 '09 at 01:23">answered Jan 14 '09 at 01:23</time> <a href="../../users/2847/john-boker" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2847.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="John Boker" /> </a> <div class="s-user-card--info"> <a href="../../users/2847/john-boker" class="s-user-card--link">John Boker</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">82,559</li> <li class="s-award-bling s-award-bling__gold" title="17 gold badges">17</li> <li class="s-award-bling s-award-bling__silver" title="97 silver badges">97</li> <li class="s-award-bling s-award-bling__bronze" title="130 bronze badges">130</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> </div> </div> <div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar"> <div class="module sidebar-linked"> <h4 id="h-linked">Linked</h4> <div class="linked"> <div class="spacer"> <a title="Vote score (upvotes - downvotes)"><div class="answer-votes answered-accepted default">2</div></a> <a href="../../questions/5802130/add-to-page-title-tag-based-on-variable-from-url" class="question-hyperlink">Add to page title tag based on variable from URL</a> </div> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>