473,788 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto prepend problem

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

Aug 28 '06 #1
5 3399
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

Aug 29 '06 #2

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_exist s('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

Aug 29 '06 #3
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_exist s('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
Aug 29 '06 #4

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

Aug 29 '06 #5

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

Aug 29 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
26510
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 += '>> %s'%dirList.pop() #(????????????) # to return
9
11854
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 automatically when the visitor arrives at the page, perhaps by using the onLoad event to call the dropdown code. The problem is, the click() event does not drop down the list, as I would have thought it might. I can successfully fire other methods...
1
2685
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. ....it pops up "x.filename", "x.prepend" and "x.word". Shouldn't it show "x.append", "x.pop", etc?
5
5045
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 CurrentUICulture to what's specified in the querystring. Since I want to allow UICulture auto detecting, I add UICulture = "auto" to page directive on each page.
37
5094
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 timestamps on each line. I would like for this to work for all the printf-line functions (fprintf, etc...) as well as C++ I/O streams (cout and cerr). The key here is that I would like to get these timestamps on the lines of text written to...
1
4191
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 less than 9 digits long prepend "0" until it is equal to 9 digits. if equal to 9 digits do nothing and select next. can anyone give me some idea as to how the syntax would look like? any help is much appreciated.
6
1548
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 warrant another table it would be sufficient to prepend the data to the existing data in the field. Sorry if this is really a MySql problem, but at the moment I can only think of a php/html hidden field solution. -- Geoff Berrow (put thecat out...
5
4832
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; but I would like to do
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4069
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 we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.