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
Unable to display contents in Second Drop Down Box
Hi All,
What I am trying to do is 2 dependent drop down boxes and when user selects su
Looking for help reading a .txt or .ini file and outputting the info.
I have a file called Info.ini and It has the following info:
Code: [General]
Online=0
I wou
How to convert this array to string
I am having problems converting this array to a string
using print_r($val[1]); I get:
Code: [
TinyMCE / Ajax Postback Problem
Hiya all,
I have a page which loads the TinyMCE editor. On the postback I obviously want to f
Strange php code found on my website
I got hacked and the following code was placed within my files:
Code: [Select]<?
/*
Variable Clash
In the past I've had variables clash. For example:
Code: <?php
$c = 5;
$ca
fire away
i launched about 4 months ago as a lagit co. i have 2 paying clients, 1probono, 1 side progect, and
Email to a friend script problems
I have this send-to-a-friend script with 2 issues:
1) When you open the form popup on a p
Why will this program not run if the variables are not global?
Hey guys I have a kind of perplexing situation that is probably simple, but I can't seem to understa
MS Access data into a html table
Hi everyone, I am quite a novice at php but I have created some helpful scripts that fetch data
f