Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php server function

<?php
  // PHP $_SERVER['...']; method
  
  // PHP file name
  echo 'PHP file name: '.$_SERVER['PHP_SELF'].'<br>';
  // Server name
  echo 'Server name: '.$_SERVER['SERVER_NAME'].'<br>';
  // HTTP host
  echo 'HTTP host: '.$_SERVER['HTTP_HOST'].'<br>';
  // Refering link
  echo 'Refering link: '.$_SERVER['HTTP_REFERER'].'<br>';
  // User agent
  echo 'User agent: '.$_SERVER['HTTP_USER_AGENT'].'<br>';
  // Script name
  echo 'Script name: '.$_SERVER['SCRIPT_NAME'];
  
  // The rest is optional

  if($_SERVER['PHP_SELF']=='/filename.php'){
    //If there is no folder
    echo 'No folder'.$_SERVER['PHP_SELF'];
  } else{
    // Echo the name of the folder containing the PHP file
    echo 'PHP file name: '.$_SERVER['PHP_SELF'];
  }
  
  // The same if statements can be used for the script name
  
  if($_SERVER['SCRIPT_NAME']=='/filename.php'){
    // If there is no folder
    echo 'No folder'.$_SERVER['SCRIPT_NAME'];
  } else{
    // Echo the name of the folder containing the PHP file
    echo 'PHP file name: '.$_SERVER['SCRIPT_NAME'];
  }
  
  echo '<a href="repl.it/@CoolWebDev">More from me...</a>';
  
  // I hope you found this helpful! 
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel query builder get data as array of array 
Php :: laravel auth 6 
Php :: php-curl 
Php :: create migration with model laravel 8 
Php :: laravel route target class not found 
Php :: Artisan command on live server 
Php :: autogenerate slug for model laravel 
Php :: compare php date with mysql date 
Php :: générer des nombres aléatoires décimaux en php 
Php :: how to change woocommerce read more text 
Php :: how to run multiple seeder at a time in laravel 
Php :: get numbers from string php 
Php :: php get list of filenames in diretory 
Php :: js unserialize 
Php :: request file create cammand laravel 
Php :: Increase the PHP memory limit 
Php :: bycrypt password php 
Php :: how to add javascript to a php file 
Php :: php check if text is blank 
Php :: laravel validation image or file 
Php :: Redirect to external domain in Laravel 
Php :: add custom helper laravel 
Php :: laravel dump] 
Php :: New Laravel Devcontainer Project Setup 
Php :: laravel cannot add foreign key constraint 
Php :: php receive post 
Php :: img src php wordpress theme child 
Php :: wordpress theme development boilerplate 
Php :: reset password symfony 
Php :: laravel get current route url 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =