PHP question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zentz
    Confirmed User
    • Nov 2003
    • 8062

    #1

    PHP question

    How can I use php virtual include to include php file but with some variables passed onto it?

    For example:

    I wanna include the file substract.php but i want it to substract 5 from 19
    to do this i have to call substract.php?a=19&b=5

    if i call <?php virtual ("substract.php?a=19&b=5"); ?> it just includes substract.php without the variables

    Help would be highly appreciated
    Programs that owe me money ---- Epassporte.com ~ $2700 | Protraffic.com ~ $2600 | XonDemand.com ~ $3000

    Email: [email protected]
  • Apache_A
    Confirmed User
    • May 2004
    • 434

    #2
    have you tied including the full URL to the php file?

    eg

    include('"http://www.yourdomain.com/substract.php?a=19&b=5");


    Also if the file is just calling a fucntion in subtract.php you can include the file and then call the fucntion in the intial script.

    eg.

    include('subtract.php');
    subtract(5,6);

    where subtract is the function within subtract.php
    ICQ:2116226

    Comment

    • Nathan
      Confirmed User
      • Jul 2003
      • 3108

      #3
      You want to virtual include it using SSI? Or what do you mean by virtual include?
      "Think about it a little more and you'll agree with me, because you're smart and I'm right."
      - Charlie Munger

      Comment

      • zentz
        Confirmed User
        • Nov 2003
        • 8062

        #4
        This is what i wanna add to my HTML
        PHP Code:
        <?php virtual ("substract.php?a=2&b=3"); ?>
        when i do that it includes just the php file
        Programs that owe me money ---- Epassporte.com ~ $2700 | Protraffic.com ~ $2600 | XonDemand.com ~ $3000

        Email: [email protected]

        Comment

        • Apache_A
          Confirmed User
          • May 2004
          • 434

          #5
          if you HTML file isn't being passed at php then they shouldn't work.

          If it is then just use the include or require commands.
          ICQ:2116226

          Comment

          • Nathan
            Confirmed User
            • Jul 2003
            • 3108

            #6
            Do you use substract.php by itself at some point? If not, why do it like that? Makes no sense.

            If you do not use it seperately, just do include('substract.php') and set the 2 variables you want to substract before the include, the substract.php will see all variables your main php sees at the include() point.

            The other usefull thing really would be using a function instead of an include file. But I am guessing this is just a simple example and what you are trying to do is more complicated.
            "Think about it a little more and you'll agree with me, because you're smart and I'm right."
            - Charlie Munger

            Comment

            • boyw_utr
              Confirmed User
              • Oct 2003
              • 310

              #7
              if a var is set in the main page where you include the substract.php you can also call it in substract.

              Like for example if $A="100" is set in main before you include the substract.php you can call $A in substract. Just as simple as that..

              If you set $A after the include it isn't availble in substract.php

              Otherwise you need to make functions an parse the var through the function like this name_function($A, $B);
              SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

              Comment

              Working...