#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    12
    Rep Power
    0
    Hey guys,
    I just started to learn PHP, and I have a strong background Borland Delphi and HTML. But, I am new to this so i was hoping someone could help me out. Are their procedures? Like you have...

    function what($var) {
    blah
    }

    and in perl you can do a simple procedure without variables like

    sub whatever{
    blah
    }

    What would the 'sub' be equivilent to in PHP? I have a error message I want posted throughout a page if there are form errors, and i know i can just do include but I would rather use a procedure, at least to learn how its done. Here's the code im using...maybe i just messed up the syntax or something...

    sub ErrorMsg {
    echo "error message here";
    }

    Hope someone can help me out,
    -Bryan
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Just define it without arguments, but you do need to include the ():

    function some_func()
    {
    do foo
    }

    then call it with

    some_func();

IMN logo majestic logo threadwatch logo seochat tools logo