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

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

get url with php

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

php current url

 $currentUrl = $_SERVER['REQUEST_URI'];
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 :: In PackageManifest.php line 131: Undefined index: name 
Php :: why php is not using datatype 
Php :: Mixed int and string keys 
Php :: wordpress remove noindex programmatically 
Php :: PHP metaphone — Calculate the metaphone key of a string 
Php :: php mysql delete from multiple tables 
Php :: laravel dynamically add remove table row 
Php :: laravel collection zip 
Php :: laravel How do I chain multiple where and orWhere clause in laravel from an Array [duplicate] 
Php :: How to post a mutlipart file using file_get_contents in php 
Php :: where post_type like 
Php :: how get end of array in foreach php 
Php :: membership_registration: city or town 
Php :: Éviter le spam de commentaires 
Php :: email in ctf 
Php :: extract email from text 
Php :: how to select specific id in laravel using isset 
Php :: rename image file using post id in wordpress programmatically 
Php :: wc get_image() return image url 
Php :: implode remove empty php 
Php :: Uncaught TypeError: call_user_func(): Argument #1 
Php :: paygate logout session on callback laravel 
Php :: laravel join with count 
Php :: laravel Add a static label/text above panel 
Php :: phpmailer 5 string attachment 
Php :: hou to fill value in input box using php 
Php :: protocals supported by php 
Php :: WP Admin Bar Dev Links 
Php :: PHP str_rot13 — Perform the rot13 transform on a string 
Php :: implode (PHP 4, PHP 5, PHP 7, PHP 8) implode — Join array elements with a string 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =