PHP Question

Discussion in 'OT Technology' started by Sexual Vanilla, Mar 31, 2007.

  1. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
    How can I create a function in PHP, such as validateCC($ccnum) (which basically takes a number and randomly returns "approved" or "denied") to be used by all scripts? The function works fine in the script where I declared it, but I would like all scripts to have access to it, so that in any script, I could simply type validateCC($variable) and it would return approved or denied. Is this even possible?
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
  3. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
  4. Sexual Vanilla

    Sexual Vanilla New Member

    Joined:
    May 23, 2005
    Messages:
    6,305
    Likes Received:
    0
    Location:
    South Carolina
    It works, but the include statement appears to have the unintended side effect of actually displaying the page you're including. I didn't necessarily want this, I just wanted access to the function that was within the page. Either that, or I'm implementing it wrong. :hs:
     
  5. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    you're implementing it wrong. Your functions should be members of a class, and the class should house nothing but code to process. Display should be handeled independently.

    Do not use the "include" statement for this. You want the "require_once();" Option. You want it to fail if it can't use the included file, and you only want it once, not more than once (that will throw an error).
     

Share This Page