0

I am trying to include a php file using a MAMP localised server:

$path = "../function/function.php";
include_once($path);

This path just doesn't seem to work. What paths do I need to use in order to include php files into other php files using MAMP locally?

The path that works when I type in the browser is:

http://localhost:8888/function/function.php
3
  • that would depend on where you're trying to include from. ../means drop back a level, then from there move forward to function and then find function.php. is that logic sound from where this code is? Commented May 10, 2013 at 17:20
  • code is in root.... localhost:8888 Commented May 10, 2013 at 17:22
  • I posted as an answer. Just FYI this is just PHP. MAMP is irrelevant to this question. Commented May 10, 2013 at 17:23

1 Answer 1

1

If this is in root, then you would include relative to root:

$path = "function/function.php";
include_once($path);
Sign up to request clarification or add additional context in comments.

4 Comments

dont forget the meaning of ../ ./ / and so on. those are very regular in coding, so knowing what they do is going to save a ton of time
If it helps, stupid would have been wasting hours and hours on it when just asking someone only takes a couple minutes.
by the way do you know anywhere that it's well explained ../ ./ / ?
kind of funny but it's hard to search for that since I believe google is not reading ../ or ./ as valid search terms. You can get the basic idea by google searching "relative paths tutorial" and reading the first few links. They are not all inclusive, but will get you started.

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.