Search
 
SCRIPT & CODE EXAMPLE
 

PHP

dir name php

<?php
dirname(__FILE__);
?>
Comment

php dirname

// dirname ( string $path [, int $levels = 1 ] ) : string

<?php
echo dirname("/etc/passwd") . PHP_EOL;
echo dirname("/etc/") . PHP_EOL;
echo dirname(".") . PHP_EOL;
echo dirname("C:") . PHP_EOL;
echo dirname("/usr/local/lib", 2);

// Above example outputs:

/*
	"/etc"
	"/" (or "" on Windows)
	"."
	"C:"
	"/usr"
*/
Comment

php dirname

/*
* 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 :: yii 2 create migration with fields 
Php :: ternary in php 
Php :: magento 1.9 get all product 
Php :: laravel pivot table model 
Php :: woocommerce disable links on specific product 
Php :: laravel get namespace 
Php :: epoch conversion php 
Php :: laravel app service provider register 
Php :: php one line if without else 
Php :: php get html with special characters 
Php :: php array current 
Php :: multe data on database laravel 
Php :: install a package only composer dont update 
Php :: how to add two string in php 
Php :: laravel drop column softdeletes 
Php :: laravel vreeze 
Php :: laravel custom abort message 
Php :: sms laravel 
Php :: drupal 8 entity_view 
Php :: socket in laravel 
Php :: test php code online free 
Php :: Eager realationship in laravel 
Php :: php get json objects by key without indez 
Php :: symfony request type 
Php :: laravel FacadesDB update 
Php :: change wordpress viewport 
Php :: foreach and forelse empty 
Php :: wp wc php if not is single product page 
Php :: php pdo delete 
Php :: warning: parameter 2 to search_by_title() expected to be a reference, value given inwp-includesclass-wp-hook.php on line 287 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =