Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get parent url from script location

/* Just ran this as is and it worked
*  OUTPUT: http://rootURL.com/dir1/parentDIR/{script.php}
*/
function get_directory(){
    $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
    $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol . "://" . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']);
}
define("ROOT_PATH", get_directory()."/" );
echo ROOT_PATH;
Comment

PREVIOUS NEXT
Code Example
Php :: increase file upload size limit 
Php :: dropdown search php mysql 
Php :: blade check if variable exists 
Php :: Laravel unique Validation with multiple input value 
Php :: php convert path from server url to link 
Php :: hasmany relationship in laravel 
Php :: laravel where condition with if 
Php :: guzzlehttp http_errors get 
Php :: laravel group concat values showing duplicate 
Php :: laravel collection nth method 
Php :: Call to undefined method CI_DB_mysqli_result::order_by() 
Php :: connexion à la base de donnée microsoftsqlserver avec php 
Php :: laravel orderby LCASE 
Php :: Fetch pivot data laravel 
Php :: Symmetric encryption in PHP 
Php :: curlopt_postfields php example 
Php :: laravel get url parameters in controller 
Php :: create array of zeros php 
Php :: Laravel unique cheque using multiple column 
Php :: parseint php 
Php :: chunk_split (PHP 4, PHP 5, PHP 7, PHP 8) chunk_split — Split a string into smaller chunks 
Php :: php code add text on existing pdf file 
Php :: laravel crud application 
Php :: wordpress get all published post 
Php :: what is php file 
Php :: laravel dependency injection 
Php :: show widget using the shortcode from php 
Php :: self vs this in php 
Php :: crypt password php 
Php :: PHP OOP - Abstract Classes 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =