Translate

Friday, 4 May 2012

Step 8: Creating the function.inc.php file

Step 8: Creating the function.inc.php file
Now we will create a file that will store all our functions, by including this file all our functions will be accessable.
It will help keep track of your functions.

File functions.inc.php:

<?php
 
require_once("mail.functions.inc.php");
require_once("user.functions.inc.php");
require_once("display.functions.inc.php");
require_once("login.functions.inc.php");
require_once("validation.functions.inc.php");
 
 function generate_code($length = 10)
{
 
        if ($length <= 0)
        {
                return false;
        }
 
        $code = "";
        $chars = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
        srand((double)microtime() * 1000000);
        for ($i = 0; $i < $length; $i++)
        {
                $code = $code . substr($chars, rand() % strlen($chars), 1);
        }
        return $code;
 }
 ?>

No comments: