PHP functions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mankolele
    New Member
    • Sep 2006
    • 63

    #1

    PHP functions

    Is it possible to mix PHP functions with normal PHP code. Does it work?

    Thanks
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by mankolele
    Is it possible to mix PHP functions with normal PHP code. Does it work?

    Thanks
    I'm not entirely sure what you are asking. Could you give a little more detail about what you are trying to do?

    Comment

    • cassbiz
      New Member
      • Oct 2006
      • 202

      #3
      Functions are put into the <?php ?> . Are you referring to php classes? If you are they are simply put a collection of functions already written which assist you to complete whatever task it is that you are working on.

      Comment

      • mankolele
        New Member
        • Sep 2006
        • 63

        #4
        I mean something like

        [PHP]

        //normal code not in a function
        if($session->logged_in)
        {
        echo "<h1 align =\"center\">Log ged In</h1>";
        echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
        ."[<a href=\"userinfo .php?user=$sess ion->username\">M y Account</a>] "
        ."[<a href=\"useredit .php\">Edit Account</a>] ";
        if($session->isAdmin())
        {
        echo "[<a href=\"admin.ph p\">Admin Center</a>] ";
        }
        echo "[<a href=\"process. php\">Logout</a>]";
        {
        //funtion
        function login($subuser, $subpass, $subremember){
        global $database, $form; //The database and form object

        /* Username error checking */
        $field = "user"; //Use field name for username
        if(!$subuser || strlen($subuser = trim($subuser)) == 0){
        $form->setError($fiel d, "* Username not entered");
        }


        [/PHP]

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          Yes, it is perfectly fine to mix the two that way.

          Comment

          Working...