Is there a way to override built in php functions without APD?
Posted on
16th Feb 2014 07:03 pm by
admin
I am trying to use the
rename_function()
override_function()
options that are built into the APD php extension. But I don't want to rely on that extension being loaded.
This is another one of my out-of-the-box ideas that presents me with the thought to override the require_once function. During this function call, I want to check for the existence of the same file in another path. If it exists then require that one.. otherwise just do normal require once.
If I use the APD extension it works fine with this:
Code: rename_function('require_once', 'require_once_orig');
override_function('require_once', '$file', 'return require_once_new($file);');
function require_once_new($file) {
$modfile = str_replace(ROOT.'/', ROOT.'/'.MODS.'/', $file);
if (file_exists($modfile)) {
require_once_orig($modfile);
} else {
require_once_orig($file);
}
}
so if original file is:
/home/public_html/site/includes/page.php
I want to check if
/home/public_html/site/mods/includes/page.php exists first and load the one I want.
I am overriding the require_once function because I am adding this to an existing framework and don't want to have to update it in all locations. This would make it completely dynamic so that all require_once calls will check for existence of the file in the other path.
Any thoughts?
No comments posted yet
Your Answer:
Login to answer
153
32
Other forums
Having Problem with Date
l have a submit buttom where user have the possibility to add a date to specify when his message s
url- go to webpage
i have an input text field and submit button.
how do i make the url entered into the textfiel
How to display value in drop down list after form has been reloaded
Please bear with me as I am very new to php and html.
I have a form with several drop down me
printing links
Hi every1
i am connecting to a table in sql and the looping through with a while ($ var = my
Regular expression tips or resources
Hello! I'm having some issues implementing the appropriate regex patter to eliminate unwanted charac
fire away
i launched about 4 months ago as a lagit co. i have 2 paying clients, 1probono, 1 side progect, and
Javascript or not?
How many people prefer javascript/ajax sites? How many prefer the good old fashion straight php sit
php ajax - two drop down list with a submit button
i have created a form with 2 drop-down list and a submit button. I would like to know how to pass th
Better Method of a Member Cloud
I assume most people know how tag clouds work, where the tags most used are bigger and the least use
Retrieving innerHTML with cURL?
Hey all (sorry I know I'm a leecher, but I soon won't be. This is my first PHP project, but not my l