Published on : August 04, 2020
Title : php.site_url
Purpose : Retrieves the URL for the current site. Returns the ‘site_url’ option with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If parameter p2 (scheme) is ‘http’ or ‘https’, is_ssl() is overridden.
Syntax : [php.site_url p1=’path’ p2=’scheme’ o.set=variable name /]
Input Parameters :
p1 : Optional parameter, path relative to the site URL. Default value is blank
p2 : Optional parameter. Scheme to give the site URL context. Default value is blank
Return Value : Site URL link with appended path (if passed in p1).
Example 1 :
Code : [php.site_url o.set=template.site_url /]
Output : string(21) “https://v4.loantap.in”
Description : Returns the https://v4.loantap.in without any appended path (as we have not passed anything via parameter p1 i.e. path) and with the appropriate protocol (as we have not passed scheme ‘http’ or ‘https’, it has returned the original protocol i.e. https)
Example 2 :
Code : [php.site_url p1=’dummy-app/semin’ o.set=template.site_url /]
Output : string(37) “https://v4.loantap.in/dummy-app/semin”
Description : Returns the https://v4.loantap.in/ with appended path (as we have passed path ‘dummy-app/semin’ via parameter p1 i.e. path) and with the appropriate protocol (as we have not passed scheme ‘http’ or ‘https’, it has returned the original protocol i.e. https)
Example 3 :
Code : [php.site_url p1=’dummy-app/semin’ p2=’http’ o.set=template.site_url /]
Output : string(36) “http://v4.loantap.in/dummy-app/semin”
Description : Returns the https://v4.loantap.in/ with appended path (as we have passed path ‘dummy-app/semin’ via parameter p1 i.e. path) and with the passed protocol (as we have passed scheme ‘http’, it has returned the protocol we have passed i.e. http)