...

View Full Version : php.net's require_once() definition of a 'script'



jussa
06-02-2007, 05:24 AM
Ok,

so i was reading on php.net website about the documention to the require and require_once() functions, and below is the part of it.


The require_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the require() statement, with the only difference being that if the code from a file has already been included, it will not be included again. See the documentation for require() for more information on how this statement works.

by script, does it mean a single webpage in your website, or any pages you visit?

i want to know, because instead of using require on all the pages that need to reference my classes, i was thinking of have a single page with require_once() for each of my classes.

i would then require_once() this reference file, in my index.php, so all my classes would be avaliable all the time... or am i thinking this in the totally wrong way?? :confused:

Thanks, Justin

CFMaBiSmAd
06-02-2007, 05:41 AM
You could use an auto_prepend_file to do this - http://php.zend.com/manual/en/ini.core.php#ini.auto-prepend-file

jussa
06-02-2007, 07:21 AM
You could use an auto_prepend_file to do this - http://php.zend.com/manual/en/ini.core.php#ini.auto-prepend-file

Hi, Thanks for your reply, and that seems to be what i need. however im in shared hosting, so i unable to edit the php.ini file to achieve this.

but is this a reasonable way to do what i want to achieve?

Thanks,

Justin

CFMaBiSmAd
06-02-2007, 07:43 AM
This can also be set in a .htaccess file.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum