You are here: Re: Using Relative Paths With include() « All PHP « IT news, forums, messages
Re: Using Relative Paths With include()

Posted by MBS on 11/16/05 20:52

Sandman <mr@sandman.net> wrote in
news:mr-FB0161.16223016112005@individual.net:

> In article <437b23d2$0$27941$892e7fe2@authen.yellow.readfreenews.net>,
> MBS <mbs@mbs.net> wrote:
>
>> "Rik" <luiheidsgoeroe@hotmail.com> wrote in news:dlf7km$6fa$1
>> @netlx020.civ.utwente.nl:
>>
>> > MBS wrote:
>> >> I am playing around with some PHP code. I want to put in an
>> >> include() function so I can include existing HTML code and output
>> >> it to the browser.
>> >>
>> >> Lo and behold PHP does not support relative paths with the
>> >> include() function!
>> >
>> > It does, works perfectly here in PHP4 and PHP5.
>> > Search your code for errors.
>> >
>> > Grtz,
>> >
>> > Rik
>> >
>> >
>> >
>>
>> No, it does not work.
>>
>> I have a file in the directory of the currently executing php code.
>> One would assume the following would work:
>>
>> include 'myfile.hmtl';
>>
>> But it does not work.
>>
>> I'm using PHP5 on WinXP and Apache 2.
>
> If that's cut'n'paste from your script, then you have a typo in the
> extension.
>
> Other than that, PHP can be set not to use "." for include dir - check
> your php.ini for your include dir. Even then, files earlier in the
> include path supersedes later ones, so if you have a "myfile.html"
> earlier in the paths it will be included instead of the relative one.
>
>
>

Well, what I've got is:

echo 'HTML code'
include 'myfile.html'
echo 'more HTML code'

It works just fine with an absolute filepath. It just doesn't work with
the relative one.

As someone stated, it must be because the file I have the include() in is
included by anothe file and I must base the filepath off of the first
file.

Thank you and thank EVERYONE for the help. I appreciate it.

MBS

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация