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
    Regular Coder
    Join Date
    Apr 2007
    Posts
    317
    Thanks
    24
    Thanked 3 Times in 3 Posts

    Making a subroutine in php

    I'm a newbie at PHP, How can i make a subroutine in php. Like using vb you can name a subroutine and store it in another file then make a call. How can i do the same thing in php?

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    sorry i dont understand what you mean by subroutine could you be a little more specific? oh i do nt no VB that could be why :P

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,092
    Thanks
    2
    Thanked 322 Times in 314 Posts
    You would create a user defined function, then call the function in your code. The function definition(s) can be kept in an external file and you include() or require() this external file to make the function definition available in the file that is making the call to it - http://www.php.net/manual/en/language.functions.php
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Regular Coder
    Join Date
    Apr 2007
    Posts
    317
    Thanks
    24
    Thanked 3 Times in 3 Posts
    Questions in your response...

    What is the difference between "require & include" versus "link" ?

    What if i don't want the function to return a value i just want it to carry out a task?

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    then you dont return a value
    read the manual on require and include and make your mind up which one to use


  •  

    Posting Permissions

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