Understand WordPress home_url()

Example 1

$url = home_url();
echo $url;

Output:

http://www.example.com

Example 2

$url = home_url( '/' );
echo $url;

Output:

http://www.example.com/

Example 3

$url = home_url( $path = '/', $scheme = https );
echo $url;

Output:

https://www.example.com/

Example 4

$url = home_url( $path = 'example', $scheme = relative );
echo $url;

Output:

/example