PHP code example of folded / url

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

    

folded / url example snippets


use function Folded\currentUrlIs;

if (currentUrlIs("/about-us")) {
  echo "We are on page /about-us";
} else {
  echo "We are somewhere else";
}

use function Folded\getCurrentUrl;

echo getCurrentUrl(); // "https://example.com/about-us?page=1"

use function Folded\getQueryString;

// Assuming we are on page https://example.com/about-us?page=1

echo getQueryString("page"); // "1"

use function Folded\getQueryString;

echo getQueryString("page", "1");

use function Folded\getQueryStrings;

// Assuming we are on page https://example.com/about-us?page=1&view=list

$queryStrings = getQueryStrings();

foreach ($queryStrings as $key => $value) {
  echo "value of $key is $value";
}

use function Folded\hasQueryString;

if (hasQueryString("page")) {
  echo "We can grab its value";
} else {
  echo "Do something else without it";
}