Answers for "get href php"

PHP
6

how to get the link of the current page in 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;  
  ?> 
Posted by: Guest on March-04-2020
2

get the value of href in string php

$a = new SimpleXMLElement('<a href="www.something.com">Click here</a>');
echo $a['href']; //it will echo www.something.com
Posted by: Guest on April-08-2022

Browse Popular Code Answers by Language