lundi 22 décembre 2014

PHP if statement help - syntax if URL is in specific directory?

I know how to edit the syntax of my PHP if statements when it relates to a specific page on my website. For example the following code works fine below:



<?php
if ($this->here == '/education') {?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php } ?>


However, I have a directory of pages that have a url like so:



http://ift.tt/16Ki0pX


For all the pages that are in the /c/ directory, I want to add an if statement like the one above so that if any page has a URL in the /c/ directory it will result in meta name="viewport" content="width=device-width, initial-scale=1


I tried the following but it doesn't appear to work:



if ($this->here == '/c/') {?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php } ?>


Is there something like a "contains" operator I can use instead of ==?


Thanks! Sorry I'm such a Noob - I'm trying to learn! :)


Aucun commentaire:

Enregistrer un commentaire