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
https://forums.phpfreaks.com/topic/33095-noob-help/
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
https://forums.phpfreaks.com/topic/33095-noob-help/#findComment-154259
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.