PHP code example of diversified-design / viaphp

1. Go to this page and download the library: Download diversified-design/viaphp 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/ */

    

diversified-design / viaphp example snippets


// Basic path joining
Via::j('/base/path', 'subdir/file.txt');  // → '/base/path/subdir/file.txt'

// Path canonicalization (cleans messy paths)
Via::j('/base/path', '../parent/file.txt');     // → '/base/parent/file.txt'
Via::j('/base/path', './current//file.txt');    // → '/base/path/current/file.txt'

// Cross-platform separator handling
Via::j('/base/path', 'subdir\\file.txt');       // → '/base/path/subdir/file.txt'

// Null and empty handling
Via::j('/base/path', null);  // → '/base/path'
Via::j('/base/path', '');    // → '/base/path'

// Identical to Via::j() but more concise in templates
$cssPath = via_join('/public/assets', 'css/main.css');
$logFile = via_join('/var/log/app', date('Y-m-d') . '.log');

// Perfect for HTML templates
echo '<link rel="stylesheet" href="' . via_join($assetBase, 'css/main.css') . '">';