The Artima Developer Community
Sponsored Link

PHP Buzz Forum
include_once Wrapper Class

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Pure-PHP

Posts: 20
Nickname: purephp
Registered: Mar, 2005

Pure-PHP is kind of Blog about PHP, and unconventional methodes to boost PHP-apps
include_once Wrapper Class Posted: Mar 19, 2005 5:16 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Pure-PHP.
Original Post: include_once Wrapper Class
Feed Title: Pure PHP - PHP unconventional
Feed URL: http://www.iran-fun.com/
Feed Description: Unconventional methodes to boost php apps
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Pure-PHP
Latest Posts From Pure PHP - PHP unconventional

Advertisement

There hase been some discussion in the recend days about the performance of include_once. Inlude_once is really slower than include. For the inclusion of the classes you can use
class_exists('PEAR') or require_once 'PEAR.php' (www.akbkhome.com/blog...);

You can also use this wrapper class for include_once and require_once, it is faster.

<?php

class includeWrapper{
    
private static $paths = array();
    
public static function includeOnce($path_file){
        if(!
in_array($path_file,self::$paths)){
            include(
$path_file);
            
self::$paths[] = $path_file;
        }
    }
    
public static function requireOnce($path_file){
        if(!
in_array($path_file,self::$paths)){
            require(
$path_file);
            
self::$paths[] = $path_file;
        }
    }
}
includeWrapper::includeOnce("Class1.class.php");
includeWrapper::requireOnce("Class1.class.php");
includeWrapper::includeOnce("Class2.class.php");

?>

Read: include_once Wrapper Class

Topic: PHP Command Line rocks Previous Topic   Next Topic Topic: is __autoload evil?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use