PHP Classes

File: eg1

Recommend this page to a friend!
  Classes of Md. Shahadat Hossain Khan Razon   Tiny URL Handler   eg1   Download  
File: eg1
Role: Example script
Content type: text/plain
Description: example script # 01
Class: Tiny URL Handler
Manipulate domains and URLs and their parts
Author: By
Last change:
Date: 8 years ago
Size: 3,370 bytes


Class file image Download
('display_errors', 1);
ini_set('display_startup_errors', 1);


$output[]='you can get current full url (with query): '.tinyURLHandler::getCurrentFullURL(false);
$output[]='you can get current full url (without query): '.tinyURLHandler::getCurrentFullURL(true);
$output[]='get current http root (without trailing slash): '.tinyURLHandler::getCurrentHttpRoot(true);
$output[]='get current http root (with trailing slash): '.tinyURLHandler::getCurrentHttpRoot(false);
$output[]='get http root from given url by getHttpRootFromUrl: '.tinyURLHandler::getHttpRootFromUrl($url);
$output[]='suppose you are middle on a process you donot know the url separator, let getQuerySap handle this';
$output[]='http://localhost/index.php - '.tinyURLHandler::getQuerySap('http://localhost/index.php').' and for http://localhost/index.php?some=query - '.tinyURLHandler::getQuerySap('http://localhost/index.php?some=query');
$output[]='now you can walk over your url by relative path. say for example your url is - '.$url;
$output[]='now you want to go two step back and anoth 1 step forward into a different folder "../../different-folder"';
$output[]=tinyURLHandler::getRelativeToAbsoluteRoot('../../different-folder', tinyURLHandler::getDirHttpURL($url));
$output[]='site protocol: '.tinyURLHandler::TUH_SITE_PROTOCOL;
$output[]='if you parse url by php parse url function, you can use unparseUrl to unparse your url from array to string:';
$output[]=tinyURLHandler::unparseUrl(parse_url($url)); # i borrow this function from
$output[]='get top level domain that help you to solve canonical issue: '.tinyURLHandler::getRootDomain(3);
$output[]='you can extract from string: '.tinyURLHandler::getRootDomainX('', 3).' OR '.tinyURLHandler::getRootDomainX('', 3);
$output[]='for country level domain helper: '.tinyURLHandler::getCountryDomainPart(3);
$output[]='if you wnat to know the folder your script stand: '.tinyURLHandler::getDirHttpURL();
$output[]='you can extract by passing your url: '.tinyURLHandler::getDirHttpURL($url);
$output[]='the most important function, the current URL: '.tinyURLHandler::get();
$output[]='you can replace any query of url by string: '.tinyURLHandler::get($url, 'q=tiny');
$output[]='you can replace any query of url by array: '.tinyURLHandler::get($url, array('some'=>'thing'));
$output[]='you can add any query of url by string: '.tinyURLHandler::get($url, 'head=tiny');
$output[]='you can add any query of url by array: '.tinyURLHandler::get($url, array('new'=>'area'));
$output[]='you can delete any query of url: '.tinyURLHandler::get($url, null, array('some'));
$output[]='instead of parse url of PHP you can use getURLParts($url), its important and nice function. here you will get sorted query, case ignored for query variable etc.';
$output[]='you can get query part form array: '.tinyURLHandler::getArray2Query(array('d1'=>'query1', 'd2'=>'query3', 'd3'=>'sample1'));
$output[]='you can get query to array like as follows -';
'<pre>'.print_r($output, true);