|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I am using the <?php include() ?> statement on my website for organizational purposes. However, one of my includes contains some PHP code. Is there any way for the server to actually parse the include? I've tried this before, and it did not parse the include. Rather, it included the file as just plain ASCII. ======================= /*EXAMPLE 1*/ /*index.php*/ .... <?php include('global/includes/footer.inc') ?> .... /*footer.inc*/ .... <p>© 1993-<?php echo date("Y") ?> Kingswood School. All rights reserved.</p> .... /*EXAMPLE 2*/ /*index.php*/ .... <?php include('global/includes/lastmod.php') ?> .... /*lastmod.php*/ .... <?php echo "This file was last modified: "; echo strftime("%A %B %d %Y"); include('whateverfilename.inc'); ?> ============================= I would like to be able to parse the include if it has php code, and in some cases, create nesting includes (an include within an include). Is this even possible? Any ideas? Any is certainly appreciated. Thanks! Steven Borrelli Web Developer Kingswood School |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Steven Borrelli wrote:
> Hello, > > I am using the <?php include() ?> statement on my website for > organizational purposes. However, one of my includes contains some > PHP code. Is there any way for the server to actually parse the > include? I've tried this before, and it did not parse the include. > Rather, it included the file as just plain ASCII. If the main page is a php file, include will also make the included page to be parsed by php. I do suggest you use semicolon after each command, no matter if it's alone between the php-tags or not. It's always better to use .php as the file extension on the included files too, this as .inc normally don't be set in the server to be parsed, which leads to that if a person gives and url like http://example.net/footer.inc they will see the full source, and if you happen to have your database login/password stored in the file, then they will know how to access it. If you don't already, it's quite good to run apache web server and avoid iss. -- //Aho |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
In article <1182309379.784775.138420@q75g2000hsh.googlegroups .com>,
Steven Borrelli <sborrelli8@gmail.com> wrote: > Hello, > > I am using the <?php include() ?> statement on my website for > organizational purposes. However, one of my includes contains some > PHP code. Is there any way for the server to actually parse the > include? I've tried this before, and it did not parse the include. > Rather, it included the file as just plain ASCII. > ======================= > /*EXAMPLE 1*/ > /*index.php*/ > ... > <?php include('global/includes/footer.inc') ?> > ... > > /*footer.inc*/ > ... > <p>© 1993-<?php echo date("Y") ?> Kingswood School. All rights > reserved.</p> > ... > > /*EXAMPLE 2*/ > /*index.php*/ > ... > <?php include('global/includes/lastmod.php') ?> > ... > > /*lastmod.php*/ > ... > <?php > echo "This file was last modified: "; > echo strftime("%A %B %d %Y"); > include('whateverfilename.inc'); > ?> > > ============================= > > I would like to be able to parse the include if it has php code, and > in some cases, create nesting includes (an include within an > include). Is this even possible? Any ideas? > > Any is certainly appreciated. Thanks! > > Steven Borrelli > Web Developer > Kingswood School Should be parsed as long as the include file has the <? and ?> tags. Most of my includes are tagged .inc and it works fine. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Tim Streater wrote:
> In article <1182309379.784775.138420@q75g2000hsh.googlegroups .com>, > Steven Borrelli <sborrelli8@gmail.com> wrote: > >> Hello, >> >> I am using the <?php include() ?> statement on my website for >> organizational purposes. However, one of my includes contains some >> PHP code. Is there any way for the server to actually parse the >> include? I've tried this before, and it did not parse the include. >> Rather, it included the file as just plain ASCII. >> ======================= >> /*EXAMPLE 1*/ >> /*index.php*/ >> ... >> <?php include('global/includes/footer.inc') ?> >> ... >> >> /*footer.inc*/ >> ... >> <p>© 1993-<?php echo date("Y") ?> Kingswood School. All rights >> reserved.</p> >> ... >> >> /*EXAMPLE 2*/ >> /*index.php*/ >> ... >> <?php include('global/includes/lastmod.php') ?> >> ... >> >> /*lastmod.php*/ >> ... >> <?php >> echo "This file was last modified: "; >> echo strftime("%A %B %d %Y"); >> include('whateverfilename.inc'); >> ?> >> >> ============================= >> >> I would like to be able to parse the include if it has php code, and >> in some cases, create nesting includes (an include within an >> include). Is this even possible? Any ideas? >> >> Any is certainly appreciated. Thanks! >> >> Steven Borrelli >> Web Developer >> Kingswood School > > Should be parsed as long as the include file has the <? and ?> tags. > Most of my includes are tagged .inc and it works fine. It depends completely on how your webserver is set up. But .php files should be parsed by every webserver which has php installed. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Jerry Stuckle wrote:
> It depends completely on how your webserver is set up. > > But .php files should be parsed by every webserver which has php installed. All files included with include(), require(), include_once() and require_once() are parsed as PHP files. This is not dependent on the filename or web server. -- Toby A Inkster BSc (Hons) ARCS [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux] [OS: Linux 2.6.12-12mdksmp, up 10:37.] dict, thes & ency http://tobyinkster.co.uk/blog/2007/0...ict-thes-ency/ |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
..oO(Jerry Stuckle)
>Interesting, because I've seen this before, and others have commented on >it, also. Maybe it was a bug in an older version of PHP - it's been a >while ago. But I had one local cohort who was using php includes (not >SSI), and his files were not being parsed when they had .inc extensions. Either a bug or something heavily wrong on the server. As mentioned in another post -- PHP includes have _nothing_ to do with the web server, they are entirely handled by the interpreter. Since you explicitly write their name in the include statement, you can call them whatever you like: require_once 'foo.bar'; require_once '42'; require_once '.o0o.'; All valid. Micha |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On 20 Jun, 12:40, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Tim Streater wrote: > > In article <1182309379.784775.138...@q75g2000hsh.googlegroups .com>, > > Steven Borrelli <sborrel...@gmail.com> wrote: > > >> Hello, > > >> I am using the <?php include() ?> statement on my website for > >> organizational purposes. However, one of my includes contains some > >> PHP code. Is there any way for the server to actually parse the > >> include? I've tried this before, and it did not parse the include. > >> Rather, it included the file as just plain ASCII. > >> ======================= > >> /*EXAMPLE 1*/ > >> /*index.php*/ > >> ... > >> <?php include('global/includes/footer.inc') ?> > >> ... > > >> /*footer.inc*/ > >> ... > >> <p>© 1993-<?php echo date("Y") ?> Kingswood School. All rights > >> reserved.</p> > >> ... > > >> /*EXAMPLE 2*/ > >> /*index.php*/ > >> ... > >> <?php include('global/includes/lastmod.php') ?> > >> ... > > >> /*lastmod.php*/ > >> ... > >> <?php > >> echo "This file was last modified: "; > >> echo strftime("%A %B %d %Y"); > >> include('whateverfilename.inc'); > >> ?> > > >> ============================= > > >> I would like to be able to parse the include if it has php code, and > >> in some cases, create nesting includes (an include within an > >> include). Is this even possible? Any ideas? > > >> Any is certainly appreciated. Thanks! > > >> Steven Borrelli > >> Web Developer > >> Kingswood School > > > Should be parsed as long as the include file has the <? and ?> tags. > > Most of my includes are tagged .inc and it works fine. > > It depends completely on how your webserver is set up. > Not for an includED file - the web server has no visibility of it. C. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
..oO(J.O. Aho)
>It's true, the file extension don't matter when you include files in a php >file, but by default a *.inc file won't be parsed if it's directly accessed > >example: http://www.example.net/myincludefile.inc > >This can be a security issue if you store database login/passwords in a *.inc >file, which you should avoid to use any other extention than *.php, which will >be parsed on a php enabled server. Of course these files should be stored outside the document root. Even a .php extension is no guarantee that no visitors will ever be able to view that file. A server update, a misconfiguration, whatever -- there are some situations where even a .php file could be delivered unparsed. Micha |
|
![]() |
| Outils de la discussion | |
|
|