PHP Clipboard | Design Clipboard

PHP Clipboard

A growing library of frequently used PHP code to help you cut, mix, order and “echo” your content on the page.

Do you have code you would like to share? Let me know.

If Condition Is Met, Show Content

Show content only when a condition is met. This can be teamed up with other conditions to include one sidebar.php file with all of your secondary navigation, and then show the proper navigation on a certain page. The code above also makes it easier to add HTML between PHP without the need for echo

Dynamically Add Class Names to a Body Tag

When building small sites without a CMS, adding PHP functions on pages can really speed up development. This code will look at the url and add the text string as class names on the body tag. For example: www.example.com/foo/bar/ the body class would be