Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Posts
    124
    Thanks
    7
    Thanked 0 Times in 0 Posts

    including php files with params

    so on php.net it says you can include a php and send that php file params by using the full address:

    PHP Code:
    <?php

    /* This example assumes that www.example.com is configured to parse .php
     * files and not .txt files. Also, 'Works' here means that the variables
     * $foo and $bar are available within the included file. */

    // Won't work; file.txt wasn't handled by www.example.com as PHP
    include 'http://www.example.com/file.txt?foo=1&bar=2';

    // Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
    // local filesystem.
    include 'file.php?foo=1&bar=2';

    // Works.
    include 'http://www.example.com/file.php?foo=1&bar=2';

    $foo 1;
    $bar 2;
    include 
    'file.txt';  // Works.
    include 'file.php';  // Works.

    ?>
    i was wondering if there is another way to include a php with params using relative notation (better practice).
    e.g. include 'file.php?foo=1&bar=2';
    Last edited by Duffman12; 11-01-2006 at 09:19 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    There's really no need for params like that if the file is in your own file system. You can simply declare the varables before the include statement and they will be available in the included file. Scope restrictions apply, of course.

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Posts
    124
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    There's really no need for params like that if the file is in your own file system. You can simply declare the varables before the include statement and they will be available in the included file. Scope restrictions apply, of course.
    ohhhh, that's what that last example is of. sweet, thanks.


  •  

    Posting Permissions

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