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
help understanding hidden input w/ php
hello i'm doing a tutorial where there are multiple forms for an edit page for a user to update thei
MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need
Upload simple problem
Really confused!! I run once and it worked, but when i tried today...it didn't work
Which par
Add code to enable passing of checkbox variable on login
Ok, I have a login page, but want to add a checkbox that when checked and successful login is made i
Need some ideas as to how to go about sorting this array...
Here's how the array's are created..
Code: <?php
while ($x = readdir($dp)) {
please help me in this update statment
hi every one
if I have table and this data in it
id name
10
problems with search form numerical "between" sending by php
I am trying to display the results of a search, on a sql database, on a web page. I set up html &quo
need help in update query
i create a form for update. there are 8 columns in my mysql table. on my main page all the data is r
INSERT for date range
Hi all
I have the following table
Code: [Select] `date` date
`day` int(2)
`
include
Hi I have this way of licensing my PHP application, and I want to know if you guys can answer some q