Here is a sample code.
The output is here in Linux server
In a windows platform the output will be
Getting current directory nameBy using getcwd() function we will get path to the current directory. From this path we can take out present working directory by using explode function
By using explode() string function we will break the path by using \ as delimiter. In this array the list element will be the current directory name. So we will find out the total number of elements present in the array by using count() function. We will subtract 1 from total element ( because the first element starts with 0 , not 1 ) to get the last element.
Here is the code.
The output is here
To display all the elements we can use like this.
Above code will work for windows system, however for Linux system we have to change explode like this.
We can find out the userid of the hosting account from this
Root directory by chroot() functionWe can shift from current directory to root directory by using chroot function. This function will return true of false based on the outcome. You must have sufficient permission to execute this function. In windows platform this function will not work. So before using it is better to check this function. Here is an simple example.
It is better to check the function by using function_exists. Here is the code
Subscribe to our YouTube Channel here
This article is written by plus2net.com team. https://www.plus2net.com