can't include 'http...foo.php', but can include 'http...foo.txt'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paul13

    can't include 'http...foo.php', but can include 'http...foo.txt'

    This seems weird, but when I use the following code,

    include 'http://www.foo.com/includes.php';

    includedfunctio n();

    I am told that it is a call to an undefined function, but
    'includedfuncti on' is on the server.

    the following includes work fine, and the run the called function with
    no trouble:

    include 'http://www.foo.com/includes.phtml' ;
    include 'http://www.foo.com/includes.txt';

    all three include.php,.ph tml & .txt are on the server and are exactly
    identical. I am running php version 4.1.1. Anyone have any ideas?
  • Senator Jay Billington Bulworth

    #2
    Re: can't include 'http...foo.php ', but can include 'http...foo.txt '

    In article <768682d0.03081 90004.dd35f7c@p osting.google.c om>,
    googlegroups@pa ul13.com (paul13) wrote:
    [color=blue]
    > This seems weird, but when I use the following code,
    >
    > include 'http://www.foo.com/includes.php';
    >
    > includedfunctio n();
    >
    > I am told that it is a call to an undefined function, but
    > 'includedfuncti on' is on the server.[/color]

    The include statement is include()'ing the _output_ of
    http://www.foo.com/includes.php, not the contents of the file.

    To demonstrate thist point, load http://www.foo.com/includes.php in your
    browser and look for your function definitions. Then load
    http://www.foo.com/includes.txt. You'll see the difference.

    hth

    --
    Bulworth : funha@fung.arg | My email address is ROT13 encoded, decode to mail
    --------------------------|--------------------------------------------------
    <http://www.phplabs.com/> | PHP scripts and thousands of webmaster resources!

    Comment

    • EMS

      #3
      Re: can't include 'http...foo.php ', but can include 'http...foo.txt '

      On 19 Aug 2003 01:04:29 -0700, googlegroups@pa ul13.com (paul13) wrote:
      [color=blue]
      >This seems weird, but when I use the following code,
      >
      >include 'http://www.foo.com/includes.php';
      >
      >includedfuncti on();
      >
      >I am told that it is a call to an undefined function, but
      >'includedfunct ion' is on the server.
      >
      >the following includes work fine, and the run the called function with
      >no trouble:
      >
      >include 'http://www.foo.com/includes.phtml' ;
      >include 'http://www.foo.com/includes.txt';
      >[/color]
      When you include it using a URL as above, the file is served from the
      webserver which parses the php script as it has a php extension. With
      the other extensions, the php code isn't parsed. Try looking at the
      URL with a browser and you'll see what I mean.

      Your include path should be a physical path to the file e.g:
      include ('/usr/local/htdocs/includes/includes.php');
      That way you can use a .php extension and nobody will see your source
      code.

      EMS

      Comment

      • paul13

        #4
        Re: can't include 'http...foo.php ', but can include 'http...foo.txt '

        >[color=blue]
        > Your include path should be a physical path to the file e.g:
        > include ('/usr/local/htdocs/includes/includes.php');
        > That way you can use a .php extension and nobody will see your source
        > code.
        >
        > EMS[/color]

        How do I use the physical location for a page on another machine?

        'http://www.foo.com/usr/local/htdocs/includes/includes.php'

        with whatever is the acurate physical location following the .com?

        Paul

        Comment

        • Ian.H [dS]

          #5
          Re: can't include 'http...foo.php ', but can include'http... foo.txt'

          On 1 Sep 2003 15:26:30 -0700 in
          <message-id:768682d0.030 9011426.b832fec @posting.google .com>
          googlegroups@pa ul13.com (paul13) wrote:
          [color=blue]
          > How do I use the physical location for a page on another machine?
          >
          > 'http://www.foo.com/usr/local/htdocs/includes/includes.php'
          >
          > with whatever is the acurate physical location following the .com?[/color]


          You can't do this.. as HTTP requests are limited by the DirectoryRoot
          (or any defined directory permissions).

          If you need to include a remote file, change the extension from .php to
          something that isn't parsed by the PHP module / interpreter (.inc is the
          most common I think).



          Regards,

          Ian

          --
          Ian.H [Design & Development]
          digiServ Network - Web solutions
          www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
          Programming, Web design, development & hosting.

          Comment

          • BKDotCom

            #6
            Re: can't include 'http...foo.php ', but can include 'http...foo.txt '

            googlegroups@pa ul13.com (paul13) wrote in message news:<768682d0. 0309011426.b832 fec@posting.goo gle.com>...[color=blue]
            >
            > How do I use the physical location for a page on another machine?
            >
            > 'http://www.foo.com/usr/local/htdocs/includes/includes.php'
            >
            > with whatever is the acurate physical location following the .com?
            >
            > Paul[/color]

            I sure hope that URL is 404.

            When you include a valid external URL you're including what that URL
            outputs (should be obvious)? So pull up
            'http://www.foo.com/includes.php' in your browser. View the source.
            That's what you're including.
            surely this is covered here:
            http://us3.php.net/manual/en/function.include.php ?

            Comment

            Working...