Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php include file for its symlink directory

/*
* 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 :: php is_link 
Php :: Merge Two Collection 
Php :: Export Database Records to CSV 
Php :: how to get post by comment in laravel 
Php :: php typecast class 
Php :: php password_hash 
Php :: laravel multiple images upload 
Php :: laravel repository design pattern 
Php :: serve https with php local 
Php :: where is view folder in laravel 
Php :: how to get private images in s3 laravel 
Php :: laravel echo 
Php :: laravel change string to text 
Php :: login as user in laravel from admin panel 
Php :: laravel mail 
Php :: php versions and features 
Php :: compress video file size php 
Php :: phpunit run one test 
Php :: if one condition 
Php :: php array_map 
Php :: serialize php 
Php :: laravel 8 
Php :: cache for php website 
Php :: php array merge without array_merge 
Php :: Mixed int and string keys 
Php :: php pass byref 
Php :: PHP Parse error: Unexpected character "" (ASCII 22) on line 1 
Php :: laravel set innodb scema builder 
Php :: redirect www to non-www wordpress multisite 
Php :: Comment exiger une longueur minimale de commentaire dans WordPress 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =