Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>did you try autoloading? <a href="http://php.net/manual/en/language.oop5.autoload.php" rel="nofollow">http://php.net/manual/en/language.oop5.autoload.php</a> .. Sorry I dont have permissions to write comments yet.. </p> <p>Updated.. Wesley is right, you will need to have the class name same as file name for autoload to work. I am sorry to assume that you are doing OOP-PHP. If not autoload will not work you will have to do it traditional way</p> <pre><code>function __autoload($class) { require ABSPATH. $class .".php"; } </code></pre> <p>Any file inside the ABSPATH with classname = filename will be automatically loaded.</p> <p>If you have various paths with different files in them than you will have to create multiple constant variables with path name. And than call them inside autoload with the specific path. </p> <p>for eg.</p> <pre><code>class Myprogram{ public function __construct(){ define('ABSPATH', '/home/dalyn/public_html/'); define('ABSPATH_1', '/home/dalyn/public_html/includes'); define('ABSPATH_2', '/home/dalyn/public_html/some_other_folder'); } function __autoload($class) { require ABSPATH. $class .".php"; require ABSPATH_1. $class .".php"; require ABSPATH_2. $class .".php"; } } //Some other file $myProg = new Myprogram(); // this will define your constants as well as autoload all the required files </code></pre> <p>and if you are not using OOP. Than you will have to define different paths as constants and include the files the way you do it now. and if you want to automate this process </p> <p>this code will be helpful. </p> <pre><code>if ($handle = opendir(ABSPATH)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." &amp;&amp; $entry != "..") { include_once ABSPATH . $entry; } } closedir($handle); } </code></pre> <p>this will include all the files present in the folder ABSPATH. You can create a function and call it with whatever path you want to put.</p> <p>Hope this helps.</p> <p>Dins</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload