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 url php

$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
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 :: yajra laravel datatables rawcolumn 
Php :: laravel create session table 
Php :: Show all laravel valet folders 
Php :: jquery send form data to php 
Php :: enum in migration laravel 
Php :: symfony messenger route 
Php :: create table laravel 
Php :: Remove prefix on category title 
Php :: laravel vue browser cache auto clear 
Php :: imagick php 
Php :: php declare array 
Php :: how to use include in php 
Php :: ci4 throw new exception 
Php :: php function 
Php :: laravel make factory 
Php :: php wpdb foreach 
Php :: php script read source code web 
Php :: array_merge 
Php :: laravel eloquent duplicate record 
Php :: laravel count array 
Php :: get data from csv file in php and print in table 
Php :: laravel sharing data 
Php :: php try json decode 
Php :: Get All dates of a month with laravel carbon 
Php :: validate names regex php 
Php :: $ is not define in laravel 
Php :: php array push 
Php :: laravel datatable render html 
Php :: if statement in laravel blade 
Php :: wordpress post add input field 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =