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 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts

    how can i pass parameters to an include file in php?

    how can i pass parameters to an include file in php?

    means can we pass like that ? no . Why and what are the other solution

    PHP Code:
    <?php include('includeFile.php')?var=2 ?>

    Advance thanks
    I am still trying to find solution

  • #2
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    424
    Thanks
    8
    Thanked 6 Times in 6 Posts
    I don't think so, but you should wait to hear back from someone more knowledgeable than me.

    What I'm really interested in, though, is your intention.
    What are you trying to achieve?

    There really are many ways to solve the same problem, and sharing you goals may reward you with more-helpful answers.

    ~ Mo

  • #3
    New Coder
    Join Date
    Dec 2009
    Posts
    39
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I want to use that var variable in includeFile.php file do u understand or not

  • #4
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    No, you cannot do that, but then again, you shouldn't have to.

    This will accomplish the same thing (assuming the variable in includeFile.php is named "$var"):
    PHP Code:
    <?php 
        $var 
    2;
        include(
    'includeFile.php')
    ?>
    John

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    Yup just assign the variable in your code beforehand. If you're wanting to get them to work with $_GET then assign to $_GET
    PHP Code:
    $_GET['var'] = 2
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

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