Hi !
I'd like to ask everyone this question. I am currently maintain a
website which have hundreds of pages and lot of subdirectories. Most of
these pages contains a common function (let's call it "foo()" on top of
each of these pages. I've tried to use auto prepend and .htaccess to
prepend a file which contains an exact function foo() that is being
used on other pages.
I kept getting error "Cannot redeclare foo() in..." when I try to use
..htaccess and auto prepend feature. I've tried to remove foo() from
each page and use the foo() in the include file instead, but this
process take too much time. Is there anyway that I can tell PHP to
ignore the foo() function that is being redeclare in each page ? (I
know that I eventually have to remove foo() in every page).
Sorry for a lengthy question.
Thank you in advance,
Lazy Pig 5 3384 la*******@gmail.com wrote:
... Is there anyway that I can tell PHP to
ignore the foo() function that is being redeclare in each page ? (I
know that I eventually have to remove foo() in every page).
Sorry, don't know of such a solution. Could you do the following?
Write a script which browses all your pages and when it finds "foo()"
just rename it to something like "foo_old()".
Cheers la*******@gmail.com wrote:
Hi !
I'd like to ask everyone this question. I am currently maintain a
website which have hundreds of pages and lot of subdirectories. Most of
these pages contains a common function (let's call it "foo()" on top of
each of these pages. I've tried to use auto prepend and .htaccess to
prepend a file which contains an exact function foo() that is being
used on other pages.
I kept getting error "Cannot redeclare foo() in..." when I try to use
.htaccess and auto prepend feature. I've tried to remove foo() from
each page and use the foo() in the include file instead, but this
process take too much time. Is there anyway that I can tell PHP to
ignore the foo() function that is being redeclare in each page ? (I
know that I eventually have to remove foo() in every page).
Sorry for a lengthy question.
Thank you in advance,
Lazy Pig
There are at least two ways you could do this: Put the declaration of
foo() inside this if block, if( !function_exists('foo')) { .... }, so
the function is only parsed if it hasnt already been declared. Another
way is put if( defined('fufile') ) {return;} define('fufile',1); at the
top of the file foo() is declared in - it quickly exists the include'd
file when it is included a 2nd/3rd/... time.
Tim
Hi !
Thank you for your response. I already tried the first method, but that
didn't work since auto prepend happened first, then the foo() function
in each page is being process next.
What do you mean "fufile" in your second method ? is it the include
file's name which contains foo() function ?
Thank you for your help,
Lazy Pig
Tim Hunt wrote:
la*******@gmail.com wrote:
Hi !
I'd like to ask everyone this question. I am currently maintain a
website which have hundreds of pages and lot of subdirectories. Most of
these pages contains a common function (let's call it "foo()" on top of
each of these pages. I've tried to use auto prepend and .htaccess to
prepend a file which contains an exact function foo() that is being
used on other pages.
I kept getting error "Cannot redeclare foo() in..." when I try to use
.htaccess and auto prepend feature. I've tried to remove foo() from
each page and use the foo() in the include file instead, but this
process take too much time. Is there anyway that I can tell PHP to
ignore the foo() function that is being redeclare in each page ? (I
know that I eventually have to remove foo() in every page).
Sorry for a lengthy question.
Thank you in advance,
Lazy Pig
There are at least two ways you could do this: Put the declaration of
foo() inside this if block, if( !function_exists('foo')) { .... }, so
the function is only parsed if it hasnt already been declared. Another
way is put if( defined('fufile') ) {return;} define('fufile',1); at the
top of the file foo() is declared in - it quickly exists the include'd
file when it is included a 2nd/3rd/... time.
Tim
la*******@gmail.com wrote:
Hi !
Thank you for your response. I already tried the first method, but that
didn't work since auto prepend happened first, then the foo() function
in each page is being process next.
What do you mean "fufile" in your second method ? is it the include
file's name which contains foo() function ?
Thank you for your help,
Lazy Pig
Hmm sorry it wont work - I misread the problem, thought you were
including a file on every page and the included file contained foo(),
having the function foo() defined every page is very different and what
I suggested won't work.
fufile was just the name of a constant to record whether a file had
been included or not, it could have been anything.
Tim la*******@gmail.com wrote:
Hi !
Thank you for your response. I already tried the first method, but that
didn't work since auto prepend happened first, then the foo() function
in each page is being process next.
Try the first method but swap auto_prepend for auto_append..
Tim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: flamesrock |
last post by:
so I know you can append a string. But how do you *prepend* a string,
as shown in the following code
#dirList =
#string = """position"""
#for x in len(dirList):
# string += '>>...
|
by: Prowler |
last post by:
In our current application we have a page whose sole purpose for existence
is to permit the user to select from a list (subsequent to our login page).
We would like to have the list drop down...
|
by: jas |
last post by:
Hi,
I just started to use DrPython and I have installed the
CodeCompletion plugin. I am using DrPython 161 (on windows) with
wxPython 2.6.1. Anyhow, when I try something like
x =
x.
...
|
by: Samuel |
last post by:
Hi,
I am running into a problem of mixing UICulture = auto and allowing users to
select culture using a dropdown list.
I am detecting a querystring, "setlang", and when found, setting the...
|
by: nobody |
last post by:
I am writing a framework that other developers will write plug-ins
for. I would like for one of the features of the framework to be to
intercept all text written to stdout/stderr and prepend...
| |
by: y0sh1 |
last post by:
I'm new at using macros in excel and need to prepend zeros to a column of data. i know i'll need an if statement with some kind of loop.
the logic goes something like, select cell, if number is...
|
by: Geoff Berrow |
last post by:
I have a record in a MySql database which can be edited. Each time it
is edited I want to give the user the opportunity to summarise the
changes, which I store in a field. It doesn't really...
|
by: lawpoop |
last post by:
Hello -
Is there an operator where I can prepend a string to a string, without
repeating the variable name? I'm aware of the concatenation operator,
where you can do
$string .= $ending;
...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |