Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php.net's require_once() definition of a 'script'

    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.

    Quote Originally Posted by PHP Documentation
    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??

    Thanks, Justin

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,131
    Thanks
    2
    Thanked 328 Times in 320 Posts
    You could use an auto_prepend_file to do this - http://php.zend.com/manual/en/ini.co...o-prepend-file
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    You could use an auto_prepend_file to do this - http://php.zend.com/manual/en/ini.co...o-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

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,131
    Thanks
    2
    Thanked 328 Times in 320 Posts
    This can also be set in a .htaccess file.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •