Home > BetterPHP-PHP-Library

BetterPHP-PHP-Library

BetterPHP-PHP-Library is a project mainly written in PHP, it's free.

A collection of PHP scripts that provide some functions to make developing in PHP easier.

A simple set of php scripts that should take some of the pain
out of developing in PHP, each file states it's dependencies 
if it has any in the comment at the top of the file.

array.func.inc.php

    - array_is_multi($array)
        checks to see if the given array is multidimensional.

error.func.inc.php

    - custom_error($msg)
        This is the same as trigger_error() except that it will
        shown the file info from the locatin where the function
        it is used in is called, not the line trigger_error() is
        called.

file.class.inc.php

    - file::get_mime($path)
        Gets the mime type of the given file using the best 
        method available, with a fall-back to using the file
        extension.

    - file::rmrf($path)
        Recursively deleted all of the files in the given folder
        and then removes that folder.

http.class.inc.php

    - http::post($url, $data, $return = true)
        Sends HTTP POST data to the given url, $data should be
        an array where the keys represent the form names and the
        values represent the values. The $return parameter
        can be set to false if the result is not needed.

    - http::get($url, $data = null, $return = true)
        Effectively the same as above, but using GET. The $data
        parameter is now optional also.

    - http::force_download($path)
        Sends the headers needed to force the download of the
        given file, then reads out the file.

    - http::force_download_raw($name, $size, $data)
        Does the same task as above but takes data directly,
        not from a file. $name is the name of the file that
        should be shown in the download window, $size is the 
        files size and $data is the raw data.

mail.class.inc.php

    Unfinished, see source.

mysql.class.inc.php

    - mysql->__construct($server, $user, $pass, $db)
        Connects tothe database, returning a object that has the
        following methods for working with mysql. The effects of
        magic_quotes are removed at this point also.

    - mysql->escape(&$data, $return = false)
        Applies mysql_real_escape_string to the $data variable,
        if $return is set to true the escaped value will also be
        returned.

    - mysql->query($sql)
        Sends the given SQL code to the MySQL server and stores
        the result resource internally for use with the following.

    - mysql->ub_query($sql)
        The same as above, but unbuffered.

    - mysql->fetch(&$row)
        Fetches the current row from the internal result resource.
        This will return false once the end of the table is reached.
        The $row variable will be populated with an assoc array
        representing the table.

    - mysql->fetch_array()
        Similar to the above, except an array of rows is returned.

    - mysql->fetch_cell(&$cell)
        Fetches the first cell in the first row of a query result.

    - mysql->fetch_last_id(&id)
        Fetched the last auto_increment number that the MySQL
        server generated.

string.func.inc.php

    - str_starts_with($needle, $haystack)
        Returns true if $haystack starts with $needle, false if
        not

    - str_ends_with($needle, $haystack)
        Returns true if $haystack ends with $needle, false if not

    - str_contains($needle, $haystack)
        Returns true if $haystack contains one or more occurrences
        of $needle

    - strlen_between($subject, $x, $y)
        Returns true if $subject is longer than $x and shorter
        than $y

validate.class.inc.php

    - validate::mysql_unique($table_name, $column_name, $column_value)
        Returns true if the given column has the given value, false
        if not. Both the column_name and the column_value can be
        arrays.

    - validate::email($email)
        Returns true if the given email address is of a valid form,
        false if not. Both this and the below url function have methods
        of performing strict validation with and without filter_var.

    - validate::url($url)
        Returns true if the given url is valid, can be reached and
        gives the HTTP status code 200.