Source for file compat.php5xx.php

Documentation is available at compat.php5xx.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */ 
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. /**
  19.  * Replace stripos()
  20.  *
  21.  * @category    PHP
  22.  * @package     PHP_Compat
  23.  * @link        http://php.net/function.stripos
  24.  * @author      Aidan Lister <aidan@php.net>
  25.  * @version     $Revision: 1.13 $
  26.  * @since       PHP 5
  27.  * @require     PHP 4.0.0 (user_error)
  28.  */
  29. if (!function_exists('stripos')) {
  30.     function stripos($haystack$needle$offset null)
  31.     {
  32.         if (!is_scalar($haystack)) {
  33.             user_error('stripos() expects parameter 1 to be string, ' .
  34.                 gettype($haystack' given'E_USER_WARNING);
  35.             return false;
  36.         }
  37.  
  38.         if (!is_scalar($needle)) {
  39.             user_error('stripos() needle is not a string or an integer.'E_USER_WARNING);
  40.             return false;
  41.         }
  42.  
  43.         if (!is_int($offset&& !is_bool($offset&& !is_null($offset)) {
  44.             user_error('stripos() expects parameter 3 to be long, ' .
  45.                 gettype($offset' given'E_USER_WARNING);
  46.             return false;
  47.         }
  48.  
  49.         // Manipulate the string if there is an offset
  50.         $fix 0;
  51.         if (!is_null($offset)) {
  52.             if ($offset 0{
  53.                 $haystack substr($haystack$offsetstrlen($haystack$offset);
  54.                 $fix $offset;
  55.             }
  56.         }
  57.  
  58.         $segments explode(strtolower($needle)strtolower($haystack)2);
  59.  
  60.         // Check there was a match
  61.         if (count($segments=== 1{
  62.             return false;
  63.         }
  64.  
  65.         $position strlen($segments[0]$fix;
  66.         return $position;
  67.     }
  68. }
  69. ?>

Documentation generated on Mon, 05 May 2008 16:18:01 +0400 by phpDocumentor 1.4.0