Write a function in a seperate place and call it in several php files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • duzhidian@gmail.com

    #1

    Write a function in a seperate place and call it in several php files

    Hello all,

    Since I need call a function in different php files, I want to put the
    funcion in a seperate file instead of copying and pasting into each php
    file.

    The benefit is that when I change the function in one place, all the
    programs will change when they call this function.

    What should I do in the PHP?

    Thanks.

    Zhidian Du

  • Iván Sánchez Ortega

    #2
    Re: Write a function in a seperate place and call it in several php files

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    duzhidian@gmail .com wrote:
    [color=blue]
    > Since I need call a function in different php files, I want to put the
    > funcion in a seperate file instead of copying and pasting into each php
    > file.[/color]
    [...][color=blue]
    > What should I do in the PHP?[/color]

    You should RTFM:



    - --
    - ----------------------------------
    Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

    Todo el mundo quiere llegar a viejo, pero nadie quiere serlo.- M. Held.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.3 (GNU/Linux)

    iD8DBQFEdqDo3jc Q2mg3Pc8RAtDgAJ 9iYy/1W3BYMb3wLbmX2o BRa4mJQACcDLyK
    OPlnmZO4GXdil/vbygAiT28=
    =GvRi
    -----END PGP SIGNATURE-----

    Comment

    • lorento

      #3
      Re: Write a function in a seperate place and call it in several php files

      <?php
      //include functions
      require_once ("lib/function1.php") ;
      require_once ("lib/function2.php") ;

      ?>

      regards,
      Lorento
      ---


      Comment

      Working...