Jump to content

Noob Help


gobbly2100

Recommended Posts

I am very new to PHP as I have been using HTML all my life and I have a noobish question to ask.

If you want to include a file that is in a seperate directory to your root how would the include look, I currently have it like this but please correct me.

<?php include("/includes/footer_links.php"); ?>

It don't seem to work so anyone who can correct it I would appreciate alot thanks.
Link to comment
Share on other sites

If you want to to grab a file from a directory that is higher up from where you are now use ../ to go up a directory. For example say you file structure is this:

+ folder1
    file1.php
+ folder2
    file2.php

Now you are currently in folder1 running file1.php. But you need to require file2.php 9which is in direcotry2) into file1.php what you'll want to do is this:
[code]include '../folder2/file2.php[/code]
That now tells PHP to go out of the current working directory and in to folder2 to get file2.php

You should not use URLs for including files. You should try to use relative paths instead.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.