Light-weight, fast, simple and powerful!
Translations of this page?:
Table of Contents


This is a simple conditional function which tests the current URI against a parameter supplied. If the paratmer matches the first element in the URI, it returns “true”; otherwise it returns “false”.


Consider the URL

  • url_start_with('fruit') will only return “false”.


This could be a useful function for using specific banner images in different sections of a website. For example, if there is a JPG image which correspsonds to the each top-level page in the site (like “produce”, above), it could be included this way:

//find the top-level page slug, and save it to a variable, e.g. $topSlug, then
<img src="<?php echo (url_start_with($topSlug)) ? $topSlug : 'default'; ?>.jpg" />

This banner would then be used for all the child-pages (e.g. “fruit” and “apples” in the example above) for that top page.

See also the url_match() function.

functions/url_start_with.txt · Last modified: 2011-09-12 00:46 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 / design by yello studio / Wolf CMS Inside