<?php
function getBaseURLPath() {
return 'https://example.com/sub-directory/';
}
function getBaseURLPathOnly() {
return '/';
}
function buildWithBaseURLPathOld($info, $baseURLPath)
{
$result = '';
if (!empty($baseURLPath)) {
$result = $baseURLPath;
if (!empty($info)) {
$path = explode('/', $info);
// Remove base path from the path info.
$extractedInfo = array_pop($path);
if (!empty($extractedInfo)) {
$result .= $extractedInfo;
}
}
}
return $result;
}
function buildWithBaseURLPathNew($info, $baseURLPath)
{
$result = '';
if (!empty($baseURLPath)) {
$result = $baseURLPath;
if (!empty($info)) {
// Remove base path from the path info.
$extractedInfo = str_replace($baseURLPath, '', $info);
// Remove starting and ending slash.
$extractedInfo = trim($extractedInfo, '/');
if (!empty($extractedInfo)) {
$result .= $extractedInfo;
}
}
}
return $result;
}
echo "Old: " . buildWithBaseURLPathOld('saml/acs',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('saml/acs',getBaseURLPath()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/saml/acs',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/saml/acs',getBaseURLPath()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/',getBaseURLPath()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('',getBaseURLPath()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('',getBaseURLPath()) . PHP_EOL;
// Case not considered where URL is not a URL...
echo "Old: " . buildWithBaseURLPathOld('saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/saml/acs',getBaseURLPathOnly()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('/',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('/',getBaseURLPathOnly()) . PHP_EOL;
echo "Old: " . buildWithBaseURLPathOld('',getBaseURLPathOnly()) . PHP_EOL;
echo "New: " . buildWithBaseURLPathNew('',getBaseURLPathOnly()) . PHP_EOL;
- Output for git.master_jit, git.master
- Old: https://example.com/sub-directory/acs
New: https://example.com/sub-directory/saml/acs
Old: https://example.com/sub-directory/acs
New: https://example.com/sub-directory/saml/acs
Old: https://example.com/sub-directory/
New: https://example.com/sub-directory/
Old: https://example.com/sub-directory/
New: https://example.com/sub-directory/
Old: /acs
New: /samlacs
Old: /acs
New: /samlacs
Old: /
New: /
Old: /
New: /
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches
Archived branches
Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:
22.69 ms | 406 KiB | 5 Q