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

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 get current page url

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

php current page

(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
Comment

PREVIOUS NEXT
Code Example
Php :: foreach skip first php 
Php :: migration bool type eloquent orm 
Php :: how to check the size of mysql database in phpmyadmin 
Php :: how to run a specific test in laravel 
Php :: sort multi array php 
Php :: php create Hmac sha256 
Php :: laravel orwhere 
Php :: composer require laravel/ui laravel 7 
Php :: how import the impliment countable php 
Php :: laravel store multiple files 
Php :: create variable in laravel blade 
Php :: symfony convert entity to array 
Php :: switch php 
Php :: Laravel 8: seed users + Jetstream teams 
Php :: php regex strin start with 
Php :: laravel get authorization bearer token 
Php :: laravel get input from request 
Php :: php create from format 
Php :: escape url string php 
Php :: carbon date format 
Php :: php from 
Php :: php pdo Check if row exists in the database 
Php :: laravel make model and controller 
Php :: php iterate through array 
Php :: remove 1 day from date in php 
Php :: PHP Deprecated: Function create_function() 
Php :: relative path php 
Php :: laravel check pagination in blade 
Php :: php parse url get path 
Php :: newline in php 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =