PHP code example of takuya / php-relative-path

1. Go to this page and download the library: Download takuya/php-relative-path library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

takuya / php-relative-path example snippets




 relative_path('/etc/nginx/sites-available', '/etc/nginx/sites-enabled');
var_dump($ret);#=>'../sites-available'



= '/etc/nginx/sites-available/example.com';
$to   = '/etc/nginx/sites-enabled/example.com';
$ret = relative_path( dirname($from),  dirname($to));
var_dump($ret.DIRECTORY_SEPARATOR.basename($from));#=>'../sites-available/example.com'


 = '/etc/nginx/sites-available/example.com';
$link  = '/etc/nginx/sites-enabled/example.com';
symlink_relative($link,$real);