note 114855 added to function.spl-autoload
| From: | EVODelavega | Date: | Tue, 15 Apr 2014 08:39:48 +0000 |
| Subject: | note 114855 added to function.spl-autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199271@lists.php.net to get a copy of this message | ||
Just thought I'd react to simast at gmail dot com's note: While he has a point in saying C
outperforms PHP, his suggestion is micro-optimization. I'm not 100% against micro-optimizing
code, but if you do, go all the way:
<?php
// Your custom class dir
define('CLASS_DIR', 'class/')
// Add your class dir to include path
set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR);
This adds the include path to THE END of the paths PHP will scan for the class file, resulting in a
bunch of misses (file-not-found's) before actually looking into the CLASS_DIR.
A more sensible approach, then would be to write
set_include_path(
CLASS_DIR.
PATH_SEPARATOR,
get_include_path()
);
----
Server IP: 72.52.91.14
Probable Submitter: 194.78.14.98
----
Manual Page -- http://php.net/manual/en/function.spl-autoload.php
Edit -- https://master.php.net/note/edit/114855
Del: integrated -- https://master.php.net/note/delete/114855/integrated
Del: useless -- https://master.php.net/note/delete/114855/useless
Del: bad code -- https://master.php.net/note/delete/114855/bad+code
Del: spam -- https://master.php.net/note/delete/114855/spam
Del: non-english -- https://master.php.net/note/delete/114855/non-english
Del: in docs -- https://master.php.net/note/delete/114855/in+docs
Del: other reasons-- https://master.php.net/note/delete/114855
Reject -- https://master.php.net/note/reject/114855
Search -- https://master.php.net/manage/user-notes.php