is it possible in anyways to unset a function
what my problem is that I have to php files which declare the same function, and if i include them both they result in an error that it can not declare the function again,
those are not my php files, so I can use if(!function_exists()) in any of them,
I found "rename_function()" but it is for PECL, can't use it
what I am trying to do is , if lets say the conflicting function name is "func"
include 'first file.php';
rename_function('func','func2'); // or unset it for now
include '2nd file.php';
5 2712
Heya, xhunter.
Try manually renaming the function in each file and using a variable to store the name of the function you want to call.
E.g., -
include 'file1.php'; // Defines 'function1'
-
-
$func = 'function1';
-
-
$func(...);
-
-
include 'file2.php'; // Defines 'function2'
-
-
$func = 'function2';
-
-
$func(...);
-
-
thanx,
but as I said, I can't change those files, not because I don't have access but because they are files from 2 sets of scripts that I have that work independently, and I just want to use some of variables set in them.
and I don't really need to use that specific function when including both of the files,
I just don't want to get the error that I can't redeclare it, so I was thinking to unset one of them to prevent conflicting.
what the function really is, is the "iif()" function commonly used,
now I can not include to files that declare the same function. and both of them need to be called this way.
Heya, xhunter.
The best advice I can offer you is to copy the functions that you need out of one of those files and creating a separate file so that there is no naming conflict.
You should make it a point to use classes since PHP doesn't support namespaces. If you had them all as static functions in a class, you'd be fine.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lawrence |
last post by:
Given a bunch of mixes variables, I'm in a situation where I can't
know what type they are.
Can I use unset to kill an object? unset($object);
Can I use unset to kill a pointer to an open...
|
by: Xerxes |
last post by:
Hi,
I have a cart, setup as an associative array (itemid=>qty). When the
cart is displayed, the quantity field is an input box and the value can
be changed to add/remove an item:
echo '<input...
|
by: Phil Powell |
last post by:
PHP:
unset($_SESSION);
In my original environment (PHP 4.3.2) this line will delete the
session variable 'mainDisplay'. But in the testing environment (PHP
4.3.6) the variable persists even...
|
by: steve |
last post by:
Dont’ make my mistake. It is costly.
Say you have defined a variable $var in your main script.
Now in a function you access it using:
global $var;
But you want to set it to null inside the...
|
by: fasanay |
last post by:
Hi everybody I have got the following PHP code which I am trying to convert to
ASP any help will be appreciated...I have done most of it but I cant find a
replace function for Unset in asp which...
|
by: frizzle |
last post by:
Hi group,
Why won't $new_var be unset in the following function?
Am i missing out something?
Greetings Frizzle.
*************************************
|
by: fasanay |
last post by:
Hi everybody I have got the following PHP code which I am trying to convert to
ASP any help will be appreciated...I have done most of it but I cant find a
replace function for Unset in asp which...
|
by: comp.lang.php |
last post by:
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF
FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA
$_POST
if ($_POST && (!is_array($leaseObj->errorArray)...
|
by: Airslash |
last post by:
Hello,
I've written a small function to delete a variable from a class' internal array.
The variables on their own are custom class objects, and I'm a bit confused about the whole pass by...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
| |