WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/trailingslashit

Description

Appends a trailing slash.

Will remove trailing slash if it exists already before adding a trailing slash. This prevents double slashing a string or path.

The primary use of this is for paths and thus should be used for paths. It is not restricted to paths and offers no specific path support.

Usage

<?php trailingslashit$string ?>

Parameters

$string
(string) (required) What to add the trailing slash to.
Default: None

Return Values

(string) 
String with trailing slash added.

Examples

<?php
$path = trailingslashit( '/home/julien/bin/dotfiles' ); 
?>

$path will now contain: /home/julien/bin/dotfiles/ (Notice the trailing slash)

Notes

Change Log

Since: 1.2.0

Source File

trailingslashit() is located in wp-includes/formatting.php.

Related

untrailingslashit()

See also index of Function Reference and index of Template Tags.