LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2014, 05:51 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 9.2
Posts: 1,078

Rep: Reputation: 48
php include from another directory can't work


Using php5.4.4-14

I tried many suggestions from the Internet, nothing works. I want to include
Code:
/home/user1/directory1/directory2/file2include
into
Code:
/home/user2/directory1/directory2/directory3/file2complete.htm
All the examples on the Internet include files from the same directory than the script that has the "include" command.

Can anyone suggest a tutorial on how to include files from remote directories or explain what I need to do?

Thank you for your help
 
Old 07-08-2014, 06:33 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,434

Rep: Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054Reputation: 1054
Exactly what did your try (paste)? and what error [message] did you get (paste)?

A note: *.htm is usually not interpreted by the PHP-engine, only *.php
 
1 members found this post helpful.
Old 07-08-2014, 07:35 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,060
Blog Entries: 4

Rep: Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163Reputation: 3163
Sometimes the documentation is easy to find . . . far easier than asking a question here in this case.
Quote:
Originally Posted by http://php.net/manual/en/function.include.php:
The include statement includes and evaluates the specified file.

The documentation below also applies to require.

Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include will finally check in the calling script's own directory and the current working directory before failing. The include construct will emit a warning if it cannot find a file; this is different behavior from require, which will emit a fatal error.
And if we follow the conveniently-included hyperlink, which leads to "php.ini directives":
Quote:
Originally Posted by http://www.php.net/manual/en/ini.core.php#ini.include-path:
include_path string
Specifies a list of directories where the require, include, fopen(), file(), readfile() and file_get_contents() functions look for files. The format is like the system's PATH environment variable: a list of directories separated with a colon in Unix or semicolon in Windows.

PHP considers each entry in the include path separately when looking for files to include. It will check the first path, and if it doesn't find it, check the next path, until it either locates the included file or returns with a warning or an error. You may modify or set your include path at runtime using set_include_path().
 
1 members found this post helpful.
Old 07-09-2014, 01:34 AM   #4
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 9.2
Posts: 1,078

Original Poster
Rep: Reputation: 48
Thank you for your answers.
After posting I found Apache2 needs to be configured, since this is the only useful thing I can use from PHP, I will give it a miss. It looks like, I can use SSI more easily and I will try that. I will return and post my findings if I am successful with that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/include/linux directory or <mykernel>/include/linux directory? redjupiter58 Programming 0 06-04-2011 03:25 PM
PHP include rblampain Programming 4 11-13-2007 11:54 PM
PHP include file directory/paths DMeerholz Linux - Software 1 07-02-2007 10:21 AM
PHP include it-s Programming 3 10-05-2005 11:07 PM
php include msound Programming 2 06-24-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration