Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php readlink

/*
* Surely you can.
* PHP has incredible built-in functionality, which is islink() and readlink(),
* There are many functions like this. See the PHP manul to learn more about it.
*/

/*
* This code is based on Ubuntu Os and applies to other 'Linux distributions' and 'Macs 
* but if you are on Windows read the PHP manual to use this approach.
*
* Server root & Symlink path : /var/www/html/my-project
* Actual path : /home/$(whoami)/my-project
* Path to file I want to add : /home/$(whoami)/my-file
*/
<?php
  
  // Including the file without checking whether the link exists or not.
  include_once(dirname(readlink($_SERVER['DOCUMENT_ROOT'])).'/my-file');

  // including the file after checking if the link exists.
  include_once(dirname(is_link($_SERVER['DOCUMENT_ROOT'])?readlink($_SERVER['DOCUMENT_ROOT']):'alternate-path').'/my-file');

?>
	  
Comment

PREVIOUS NEXT
Code Example
Php :: install multiple php versions windows 
Php :: optional parameter in laravel 
Php :: php code add text on existing pdf file 
Php :: laravel mass update relationship 
Php :: php get last 3 elements of array 
Php :: php object to json 
Php :: yajra datatables html column bulder example 
Php :: if user not signed in redirected to login laravel from route 
Php :: laraval routing 
Php :: The last ship -inurl:(htm/html/php/pls/txt) intitle:index.of "last modified" (mp4/wma/aac/avi) 
Php :: if certain condition is met exit if block php 
Php :: date comparison function in php 
Php :: displaying dates using php code 
Php :: php get variable name as a string 
Php :: codeigniter sms send 
Php :: require password confirm laravel 
Php :: laravel routing 
Php :: laravel @env 
Php :: insert into php myqsl 
Php :: symfony 3.4 cache control 
Php :: latest php version 
Php :: open phpstorm from terminal 
Php :: php array_push 
Php :: php array form 
Php :: php system info script 
Php :: Mirror Inverse Program in php 
Php :: How to post a mutlipart file using file_get_contents in php 
Php :: radio button in php form 
Php :: "^" means in php 
Php :: eventon php code 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =