PHP Template Function: full_url Print

  • 0

Description:

This will convert the path to a file to a full qualified URL. If the path passed along is already a full qualified URL, this function will return its output.

Common Location:

/cms_admin/phptemplate/<templatefolder>/functions/standard.tpl

Usage:

<?= full_url("/path/to/file.html"); ?>

<?= full_url("http://yourdomain.com/path/to/file.html"); ?>

Arguments

1) The path to the file / location.

Output

If this code is being run on yourdomain.com, the output of this function will be:

http://yourdomain.com/path/to/file.html

http://yourdomain.com/path/to/file.html

If this code is being run on yourdomain2.com, the output listed above will be:

http://yourdomain2.com/path/to/file.html

http://yourdomain.com/path/to/file.html

This is because if there no absolute URL specified, full_url() will substitute the existing HTTP_HOST name in its place.

 


Was this answer helpful?

« Back