Login   Register  
PHP Classes
elePHPant
Icontem

File: fixed.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Manuel Lemos  >  Fixed functions broken before PHP 4.2.0  >  fixed.php  
File: fixed.php
Role: Class source
Content type: text/plain
Description: Class with fixed functions and the respective standalone function wrappers
Class: Fixed functions broken before PHP 4.2.0
Fix for broken PHP functions.
 

Contents

Class file image Download
<?php

/*
 * fixed.php
 *
 * Class that provides functions with the original functionality that
 * PHP developers broke in before PHP 4.1.0 release.  
 *
 * @(#) $Id: fixed.php,v 1.3 2002/07/16 04:23:43 mlemos Exp $
 *
 */

class fixed_class
{
    var 
$next_token="";
    var 
$php_version=0;

    Function 
dirname($path)
    {
        
$end=strrpos($path,"/");
        return((
GetType($end)=="integer" && $end>1) ? substr($path,0,$end) : "");
    }

    Function 
strtok($string,$separator="")
    {
        if(!
strcmp($separator,""))
        {
            
$separator=$string;
            
$string=$this->next_token;
        }
        for(
$character=0;$character<strlen($separator);$character++)
        {
            if(
GetType($position=strpos($string,$separator[$character]))=="integer")
            {
                
$this->next_token=substr($string,$position+1);
                return(
substr($string,0,$position));
            }
        }
        
$this->next_token="";
        return(
$string);
    }

    Function 
odbc_fetch_into($result,$row,&$array)
    {
        if(
$this->php_version==0)
        {
            
$version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7");
            
$this->php_version=$version[0]*1000000+$version[1]*1000+$version[2];
        }
        if(
$this->php_version>=4002000)
            return(
odbc_fetch_into($result,$array,$row));
        elseif(
$this->php_version>=4000005)
            return(
odbc_fetch_into($result,$row,$array));
        else
            return(@
odbc_fetch_into($result,$row,&$array));
    }

};

$fixed=new fixed_class;

function 
fixed_dirname($path)
{
    global 
$fixed;

    return(
$fixed->dirname($path));
}

function 
fixed_strtok($string,$separator)
{
    global 
$fixed;

    return(
$fixed->strtok($string,$separator));
}

function 
fixed_odbc_fetch_info($result,$row,&$array)
{
    global 
$fixed;

    return(
$fixed->odbc_fetch_into($result,$row,$array));
}

?>