Php Readlink Function

[Solved] Php Readlink Function | Php - Code Explorer | yomemimo.com
Question : php readlink

Answered by : gopi-krishnan-rotimucsw6z8

/*
* 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');
?> 

Source : | Last Update : Fri, 20 May 22

Answers related to php readlink function

Code Explorer Popular Question For Php