2

I am trying to change the path of a file (saved in /foo/bar directory) to the root

forexample

www.example.com/foo/bar/user.php 

to

www.example.com/user.php 

using chroot() function

<?php
chroot("/foo/bar/user.php");
$n=getcwd();
echo $n; 

it's not working, I am getting the following php error :

call to undefined function chroot() 

I am using php 5.3*, But I have also tested it on 5.4+ , still the same error. I am not sure if it is because of the the versions or something else,

Please help!

1
  • After reading your question twice, I have no idea what you expect the chroot function to do. What you did try to do with it makes no sense. The argument has to be a directory, and you appear to be giving it a file name. And there is no foo in the root of any of the standards I have come across, so the given path wouldn't exist either way. Commented May 30, 2015 at 4:37

1 Answer 1

3

Note the following from the docs page:

This function is only available to GNU and BSD systems, and only when using the CLI, CGI or Embed SAPI. Also, this function requires root privileges.

Are you trying to use it on a Windows platform? If so this will not work.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes,I am on the windows platform, it means the function is not available for me, anyway, thanks for the useful information and link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.