Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Get Current Page URL in PHP

<?php
$uri = $_SERVER['REQUEST_URI'];
echo $uri; // Outputs: URI 

$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; 
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo $url; // Outputs: Full URL 

$query = $_SERVER['QUERY_STRING'];
echo $query; // Outputs: Query String
?>
Comment

get current page php

<?php  
    if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')   
         $url = "https://";   
    else  
         $url = "http://";   
    // Append the host(domain name, ip) to the URL.   
    $url.= $_SERVER['HTTP_HOST'];   
    
    // Append the requested resource location to the URL   
    $url.= $_SERVER['REQUEST_URI'];    
      
    echo $url;  
  ?>   
Comment

current page link using php

$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $actual_link ;
Comment

php current page url

$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
$host     = $_SERVER['HTTP_HOST'];
$script   = $_SERVER['SCRIPT_NAME'];
$params   = $_SERVER['QUERY_STRING'];
 
$currentUrl = $protocol . '://' . $host . $script . '?' . $params;
 
echo $currentUrl;
Comment

php current url

 $currentUrl = $_SERVER['REQUEST_URI'];
Comment

current page link using php

$url=$_SERVER['REQUEST_URI'];
echo $url;
Comment

php get current page url

<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>
Comment

php current url

function url_origin( $s, $use_forwarded_host = false )
{
    $ssl      = ( ! empty( $s['HTTPS'] ) && $s['HTTPS'] == 'on' );
    $sp       = strtolower( $s['SERVER_PROTOCOL'] );
    $protocol = substr( $sp, 0, strpos( $sp, '/' ) ) . ( ( $ssl ) ? 's' : '' );
    $port     = $s['SERVER_PORT'];
    $port     = ( ( ! $ssl && $port=='80' ) || ( $ssl && $port=='443' ) ) ? '' : ':'.$port;
    $host     = ( $use_forwarded_host && isset( $s['HTTP_X_FORWARDED_HOST'] ) ) ? $s['HTTP_X_FORWARDED_HOST'] : ( isset( $s['HTTP_HOST'] ) ? $s['HTTP_HOST'] : null );
    $host     = isset( $host ) ? $host : $s['SERVER_NAME'] . $port;
    return $protocol . '://' . $host;
}

function full_url( $s, $use_forwarded_host = false )
{
    return url_origin( $s, $use_forwarded_host ) . $s['REQUEST_URI'];
}

$absolute_url = full_url( $_SERVER );
echo $absolute_url;
Comment

PREVIOUS NEXT
Code Example
Php :: php server self 
Php :: generate random unique hex color code using php 
Php :: get url segment in php 
Php :: php artisan serve port 
Php :: user-agent cURL php 
Php :: get start of month end of month carbon 
Php :: Module php7.4 does not exist! 
Php :: php get first 5 characters of string 
Php :: php rtrim comma 
Php :: create folder php 
Php :: get featured image url 
Php :: if post php 
Php :: explode foreach 
Php :: woocommerce product image zoom on hover disable 
Php :: laravel command to create symlink storage 
Php :: php get next saturday 
Php :: laravel get current route name 
Php :: php remove null bytes from string 
Php :: clear bootstrap cache laravel 
Php :: create laravel project specific version 
Php :: Call to undefined function str_limit() laaravel8 
Php :: change php version on mac 
Php :: how to traverse characters in a string in a for loop in php 
Php :: wordpress get taxonomy of a post 
Php :: background image in laravel blade 
Php :: url encode php 
Php :: get parent page link wordpress 
Php :: remove comma in numeric in php 
Php :: get last 30 days records in laravel 
Php :: php http build query 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =