mercredi 17 juin 2015

php if elseif wildcards based on URLs

Searched high and low for an easier way to do what I do...

I have a function that produces $absLink result as 'http://ift.tt/1JZaS8u'

I then use this for php if and elseif to do things like:

<?php else if ($absLink == 'http://ift.tt/1MMUW8J' { ?> This the homepage <?php } elseif ($absLink == 'http://ift.tt/Wq84Ly' { ?> This the about page <?php } else { ?> This probably the 404 not found page <?php } ?>

But sometimes URLs get really deep and I'd like to include similar css styles for multiple pages. Let's say /about/ also has /about/staff and about/mission-statement/ and in the future more pages will be added... Can I do a wild card? In my mind it would work like this:

<?php if ($absLink == 'http://ift.tt/1MMUW8L') { ?> Everything in the about directory follows suit to everything here <?php } else { ?> Rejection happens here lol <?php } ?>

Make sense? p.s. $absLink stands for Absolute Link, although I removed http:// from it recently cause that's just a non-useful annoyance I decided.

Aucun commentaire:

Enregistrer un commentaire