variables in the includes

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

    variables in the includes

    I hate to ask an obvious question but I'm trying not to mess up
    anything worse than it is already. I have all these variables in-
    line. Can I do an include and take them off the file into an included
    file?

    $with_reserve = $sessionVars["SELL_with_rese rve"];
    $reserve_price = $sessionVars["SELL_reserve_p rice"];
    $minimum_bid = $sessionVars["SELL_minimum_b id"];
    $pict_url=$sess ionVars["SELL_pict_ url"];
    $imgtype = $sessionVars["SELL_file_uplo aded"];
    $title = $sessionVars["SELL_title "];
    $description = $sessionVars["SELL_descripti on"];
    $pict_url = $sessionVars["SELL_pict_ url"];
    $atype = $sessionVars["SELL_atype "];
    $adultonly = $sessionVars["SELL_adultonly "];
    $iquantity = $sessionVars["SELL_iquantity "];
    $buy_now = $sessionVars["SELL_with_buy_ now"];
    $buy_now_price = $sessionVars["SELL_buy_now_p rice"];
    $duration = $sessionVars["SELL_durat ion"];
    $relist = $sessionVars["SELL_relis t"];
    $increments = $sessionVars["SELL_increment s"];
    $customincremen t = $sessionVars["SELL_custominc rement"];
    $country = $sessionVars["SELL_count ry"];
    $location_zip = $sessionVars["SELL_location_ zip"];
    $shipping = $sessionVars["SELL_shipp ing"];
    $shipping_terms = $sessionVars["SELL_shipping_ terms"];
    $payment = $sessionVars["SELL_payme nt"];
    $international = ($sessionVars["SELL_internati onal"])?"on":"";
    $sellcat = $_SESSION['sellcat'];
    $invitedlists = $sessionVars["SELL_invitedli sts"];
    $private = $sessionVars["SELL_priva te"];
    if($private != 'y') $private = 'n';
    $sendemail = $sessionVars["SELL_sendemail "];
    $blacklists = $sessionVars["SELL_blacklist s"];
    $txt = $sessionVars["SELL_txt"];
    $num = $sessionVars["SELL_num"];
    $buy_now_only = $sessionVars["SELL_buy_now_o nly"];


    Here are my includes:

    include './includes/config.inc.php' ;
    include $include_path.' dates.inc.php';
    include $include_path.' auction_types.i nc.php';
    include $include_path.' countries.inc.p hp';
    include $include_path.' datacheck.inc.p hp';
    include $include_path.' wordfilter.inc. php';
    include $include_path.' converter.inc.p hp';
    include $include_path.' functions.inc.p hp';


    So would it be something like:
    include $include_path.' variables.inc.p hp';


    assuming it is in the includes directory?

    thanks you have been a great help.
  • Guillaume

    #2
    Re: variables in the includes

    JRough a écrit :
    I hate to ask an obvious question but I'm trying not to mess up
    anything worse than it is already. I have all these variables in-
    line. Can I do an include and take them off the file into an included
    file?
    Not really clean, but yes you can do it.
    Include file is some kind of seperation to make your code cleaner, and
    to avoid duplicate functions/portions. But it works just as is the
    included file content was copied/pasted in place of the include function.

    Though, I said not really clean, cause it's not easy for maintainers
    afterward to keep track of everything if there is functions somewhere,
    variables somewhere else, defines here, config there... Usually I would
    hate having variables somewhere else.

    Regards
    --
    Guillaume

    Comment

    • JRough

      #3
      Re: variables in the includes

      On May 13, 9:11 am, Guillaume <ggra...@NOSPAM .gmail.com.INVA LID>
      wrote:
      JRough a écrit :
      >
      I hate to ask an obvious question but I'm trying not to mess up
      anything worse than it is already. I have all these variables in-
      line. Can I do an include and take them off the file into an included
      file?
      >
      Not really clean, but yes you can do it.
      Include file is some kind of seperation to make your code cleaner, and
      to avoid duplicate functions/portions. But it works just as is the
      included file content was copied/pasted in place of the include function.
      >
      Though, I said not really clean, cause it's not easy for maintainers
      afterward to keep track of everything if there is functions somewhere,
      variables somewhere else, defines here, config there... Usually I would
      hate having variables somewhere else.
      >
      Regards
      --
      Guillaume
      Okay, does that mean you leave the functions in-line also?

      Comment

      • JRough

        #4
        Re: variables in the includes

        On May 13, 9:11 am, Guillaume <ggra...@NOSPAM .gmail.com.INVA LID>
        wrote:
        JRough a écrit :
        >
        I hate to ask an obvious question but I'm trying not to mess up
        anything worse than it is already. I have all these variables in-
        line. Can I do an include and take them off the file into an included
        file?
        >
        Not really clean, but yes you can do it.
        Include file is some kind of seperation to make your code cleaner, and
        to avoid duplicate functions/portions. But it works just as is the
        included file content was copied/pasted in place of the include function.
        >
        Though, I said not really clean, cause it's not easy for maintainers
        afterward to keep track of everything if there is functions somewhere,
        variables somewhere else, defines here, config there... Usually I would
        hate having variables somewhere else.
        >
        Regards
        --
        Guillaume
        Actually that makes sense, an include would be for functions that are
        repeated not just called once. The problem is I am trying to organize
        something htat needs to be rewritten. Their probably are functions
        that should be written better.
        thanks,

        Comment

        • AnrDaemon

          #5
          Re: variables in the includes

          Greetings, JRough.
          In reply to Your message dated Tuesday, May 13, 2008, 20:31:20,
          I hate to ask an obvious question but I'm trying not to mess up
          anything worse than it is already. I have all these variables in-
          line. Can I do an include and take them off the file into an included
          file?
          >>
          >Not really clean, but yes you can do it.
          >Include file is some kind of seperation to make your code cleaner, and
          >to avoid duplicate functions/portions. But it works just as is the
          >included file content was copied/pasted in place of the include function.
          >>
          >Though, I said not really clean, cause it's not easy for maintainers
          >afterward to keep track of everything if there is functions somewhere,
          >variables somewhere else, defines here, config there... Usually I would
          >hate having variables somewhere else.
          Actually that makes sense, an include would be for functions that are
          repeated not just called once. The problem is I am trying to organize
          something htat needs to be rewritten. Their probably are functions
          that should be written better.
          thanks,
          Then think about it as when You're doing Your house cleanup.
          1. Classify things.
          2. Arrange them by some attributes.
          3. Separate and store them depends on the arrangement.


          --
          Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

          Comment

          • C. (http://symcbean.blogspot.com/)

            #6
            Re: variables in the includes

            On 13 May, 15:37, JRough <jlro...@yahoo. comwrote:
            I hate to ask an obvious question but I'm trying not to mess up
            anything worse than it is already. I have all these variables in-
            line. Can I do an include and take them off the file into an included
            file?
            >
            $with_reserve = $sessionVars["SELL_with_rese rve"];
            $reserve_price = $sessionVars["SELL_reserve_p rice"];
            $minimum_bid = $sessionVars["SELL_minimum_b id"];
            $pict_url=$sess ionVars["SELL_pict_ url"];
            $imgtype = $sessionVars["SELL_file_uplo aded"];
            $title = $sessionVars["SELL_title "];
            $description = $sessionVars["SELL_descripti on"];
            $pict_url = $sessionVars["SELL_pict_ url"];
            $atype = $sessionVars["SELL_atype "];
            $adultonly = $sessionVars["SELL_adultonly "];
            $iquantity = $sessionVars["SELL_iquantity "];
            $buy_now = $sessionVars["SELL_with_buy_ now"];
            $buy_now_price = $sessionVars["SELL_buy_now_p rice"];
            $duration = $sessionVars["SELL_durat ion"];
            $relist = $sessionVars["SELL_relis t"];
            $increments = $sessionVars["SELL_increment s"];
            $customincremen t = $sessionVars["SELL_custominc rement"];
            $country = $sessionVars["SELL_count ry"];
            $location_zip = $sessionVars["SELL_location_ zip"];
            $shipping = $sessionVars["SELL_shipp ing"];
            $shipping_terms = $sessionVars["SELL_shipping_ terms"];
            $payment = $sessionVars["SELL_payme nt"];
            $international = ($sessionVars["SELL_internati onal"])?"on":"";
            $sellcat = $_SESSION['sellcat'];
            $invitedlists = $sessionVars["SELL_invitedli sts"];
            $private = $sessionVars["SELL_priva te"];
            if($private != 'y') $private = 'n';
            $sendemail = $sessionVars["SELL_sendemail "];
            $blacklists = $sessionVars["SELL_blacklist s"];
            $txt = $sessionVars["SELL_txt"];
            $num = $sessionVars["SELL_num"];
            $buy_now_only = $sessionVars["SELL_buy_now_o nly"];
            >
            Here are my includes:
            >
            include './includes/config.inc.php' ;
            include $include_path.' dates.inc.php';
            include $include_path.' auction_types.i nc.php';
            include $include_path.' countries.inc.p hp';
            include $include_path.' datacheck.inc.p hp';
            include $include_path.' wordfilter.inc. php';
            include $include_path.' converter.inc.p hp';
            include $include_path.' functions.inc.p hp';
            >
            So would it be something like:
            include $include_path.' variables.inc.p hp';
            >
            assuming it is in the includes directory?
            >
            thanks you have been a great help.
            An include file would be better, but extract() might be a simpler/
            faster/neater solution.

            C.

            Comment

            • Guillaume

              #7
              Re: variables in the includes

              JRough a écrit :
              Okay, does that mean you leave the functions in-line also?
              Usually my structure is this one:
              - functions.inc.p hp contains all my functions except the ones I use only
              on a specific page
              - config.inc.php contains the server configuration (basedir, default
              skin, etc...) and the constants
              - connect.inc.php contains the DB parameters
              - session.inc.php whenever I use them

              That's all, everything else, including variables definitions, goes in
              the code, where they are supposed to be used.

              Regards,
              --
              Guillaume

              Comment

              Working...