+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, PHP Help - Include in Coding and Web Development; I have the following script: <?php if (file_exists($CFG->dataroot.'/1/theme/navbar.php')) if (empty($CFG->slasharguments)) { ?> <?php print $CFG->httpswwwroot.'/file.php?file=/1/theme/navbar.php' ?> <?php } else { ...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30

    PHP Help - Include

    I have the following script:

    <?php if (file_exists($CFG->dataroot.'/1/theme/navbar.php'))
    if (empty($CFG->slasharguments)) { ?>
    <?php print $CFG->httpswwwroot.'/file.php?file=/1/theme/navbar.php' ?>
    <?php } else { ?>
    <?php print $CFG->httpswwwroot.'/file.php/1/theme/navbar.php' ?>
    <?php } else { }?>

    This looks for the file navbar.php and if it exists it outputs:

    http://localhost/184/file.php/1/theme/navbar.php

    But i need it to output like this:

    <?php include("http://localhost/184/file.php/1/theme/navbar.php"); ?>

    Can anyone help?

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,406
    Thank Post
    640
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    324
    Do you mean just to include that file it mentions; or to output to the screen the whole 'include' bit?

    Code:
    <?php
    if (file_exists($CFG->dataroot.'/1/theme/navbar.php'))
    if (empty($CFG->slasharguments)) {
      include($CFG->httpswwwroot.'/file.php?file=/1/theme/navbar.php');
    } else {
      include($CFG->httpswwwroot.'/file.php/1/theme/navbar.php');
    } else {
    
    }
    ?>

  3. #3

    Join Date
    Jul 2007
    Location
    Devon
    Posts
    233
    Thank Post
    8
    Thanked 9 Times in 8 Posts
    Rep Power
    16
    awww, webman beat me too it *runs off to find brain food*

  4. #4

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30
    Sorry i want to include the file, i dont want to display that line.

    Navbar.php contains the links that should appear in my navbar.

    So the html shows the contents of the navbar.php file.
    Last edited by danIT; 26th November 2008 at 09:40 PM.

  5. #5

    Join Date
    Feb 2008
    Location
    UK
    Posts
    44
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Use file_get_contents() or a similar function instead of include. Print out the contents using the file_get_contents() function; for example:

    PHP Code:
    print file_get_contents($CFG->httpswwwroot.'/file.php?file=/1/theme/navbar.php'); 

  6. #6

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30
    Bloomin marvelous thanks guys! Works a treat!

SHARE:
+ Post New Thread

Similar Threads

  1. php and sql ?
    By mac_shinobi in forum Web Development
    Replies: 15
    Last Post: 21st October 2008, 09:43 AM
  2. PHP Help!
    By Cravon in forum Coding
    Replies: 2
    Last Post: 20th November 2007, 05:05 PM
  3. Help with PHP
    By Gatt in forum Web Development
    Replies: 1
    Last Post: 14th November 2006, 09:01 PM
  4. php help
    By beeswax in forum Windows
    Replies: 33
    Last Post: 14th October 2005, 04:51 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •