require-once

How can I tune the PHP realpath cache?

Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once() and include_once() can take advantage of it. There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how ...

What is the best way to include PHP libraries when using static factory pattern?

I have several static factory patterns in my PHP library. However, memory footprint is getting out of hand and we want to reduce the number of files required during execution time. Here is an example of where we are today: require_once('Car.php'); require_once('Truck.php'); abstract class Auto { // ... some stuff ... public st...

PHP/HTML/CSS: IE acting weird when using require_once()

Now this is the most weird problem I've ever had in PHP. All pages looks normal except one; when I first saw the problem I thought it was one of these common problems with IE and stylesheets (I've got a specific CSS-file on this page). I tried to exclude the CSS-file just to ensure that the problem really was in this file, but it wasn't...

strange php problem... require_once ignored on windows

strange problem with php on windows... my application loads a 'core' file that loads a settings file, registers autoloads, does initialization etc. at the top of the core file I have include_once("config.php"); this works fine for anything in the current directory, if I include the core file from a separate directory though it just silen...

PHP and some global variables

require_once'modules/logger.php'; $Logger = new Logger(); require_once 'templates/list.php'; $Templates = new templatesList(); require_once 'widgets/list.php'; $Widgets = new widgetsList(); I use $Logger in templates/list.php and in widgets/list.php. $Templates I use in /widget...

PHP: Failed to open required file that exists

I am trying to include the Zend_Service_Amazon_S3 file by using require_once 'Zend/Service/Amazon/S3.php'; I have also included in the include path the directory where the entire Zend library is located, AND the installation is inside Zend Server CE (which includes the Zend Framework by default). However, no matter what I try, I only ...

PHP script unable to find a file when called by a flash program

I'm working on a program right now that calls the script mail.php located in /var/www/vhosts/company/httpdocs. mail.php is trying to execute require_once dirname(__FILE__).'/../pear/Mail.php' to do an smtp send and the require_once is failing. My PEAR directory's located in /var/www/vhosts/company/pear. I then tried to add /var/www/vhost...

php require_once path confusion

Hi, I was writing an web app in php, when i encountered a strange situation. I wish to clear my confusion. To illustrate my problem, consider a web app of this structure: / index.php f1/ f1.php f2/ f2.php contents of these files: index.php: <?php require_once("f1/f1.php"); ?> f1.php: <?php require_onc...

php require_once not working the way I want it to.. relative path issue

I'm having problems assigning a relative path to require_once. I'm sure it's something simple that I'm not seeing... folder directory structure level 1: site level 2: include level 2: class so... site/include/global.php <-- this is where function autoload is being called from site/class/db.php when I attempt to use function__autoload...

Is PHP's require_once() what I need if I want my site to load if AND ONLY IF the menu loads correctly?

I'm kind of confused. I would put all the HTML for the menu in a .php file and have the engine require it right? ...

Optimizing PHP require_once's for low disk i/o?

Q1) I'm designing a CMS (-who isn't!) but priority is being given to caching. Literally everything is cached. DB rows, DB id queries, Configuration data, processed data, compiled templates. Currently it has two layers of caching. The first is a opcode cache or memory cache such as apc, eaccelerator, xcache or memcached. If an entry is ...

PHP include once.

Is it more efficient to use PHP's include_once or require_once instead of using c-like include with a header guard? i.e, include_once 'init.php'; VERSUS include 'init.php'; //contents of init.php if (!defined('MY_INIT_PHP')) { define('MY_INIT_PHP', true); ... } ...

Require_once external vars and share those with other funcions in a php class

Hi all, I have an external file with some vars to require in my php class and share those with all functions of my class: vars.inc: <?php $a = 1; ?> class.php: <?php class A{ public function __construct(){ require_once("vars.inc"); } public function aB{ echo $a; } } ?> but it doesn't work: the $a var is undefined ...

require_once in php

I have a php file which has a require_once Statement (?) this file is then in included in 2 other php files, one php file is in a sub directory so the layout is like this ("file1" and "file2" include the file "included" which require_onces the "required")# L--subfolder1 | L--file1 L--subfolder2 | L--required L--file2 L--included...

What is the scope of require_once in PHP?

Simple question: Is the scope of require_once global? For example: <?PHP require_once('baz.php'); // do some stuff foo ($bar); function foo($bar) { require_once('baz.php'); // do different stuff } ?> When foo is called, does it re-parse baz.php? Or does it rely on the already required file from the main php file (analagou...

Foolishness Check: PHP Class finds Class file but not Class in the file.

I'm at a loss here. I've defined an abstract superclass in one file and a subclass in another. I have required the super-classes file and the stack trace reports to find an include it. However, it then returns an error when it hits the 'extends' line: Fatal error: Class 'HTMLBuilder' not found in View/Markup/HTML/HTML4.01/HTML4_01Buil...

How can I speed up a 1800-line PHP include? It's slowing my pageload down to 10sec/view

I designed my code to put all important functions in a single PHP file that's now 1800 lines long. I call it in other PHP files--AJAX processors, for example--with a simple "require_once("codeBank.php")". I'm discovering that it takes about 10 seconds to load up all those functions, even though I have nothing more than a few global arr...

Include, require & require_once

Hi there. Today I've tried to include file that returns object. I always use require_once, however now I've noticed weird behavior of it. File main.php $lang = false; $lang->name = "eng"; $lang->author = "Misiur"; $lang->text = "Text is test"; $lang->undefined = "Undefined"; return $lang; File index.php $lang = include('langs/eng/m...

Should we use require_once instead header location?

Hello commnunity, i have somthing like this: (if this page needs the user to be logged) if(!isset($_SESSION['usr_id'])){ //if not a logged user $_SESSION['redir']=curPageURL();//Saving the current page for the redirection header('Location: ../Session/loginFrm.php'); } and in loginFrm.php, we do: {...after validation...

Prevent PHP require_once from ever running

Debugging someone else's PHP code, I'd like to selectively override one of their classes. The class is included via: require_once('classname.php'); But, that appears in various places in the application. I'd rather 'simulate' the require_once, so that it never gets run at all. I.e. just define class classname as I want it. Then, t...