473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

unset a function

42
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';
Jul 31 '07 #1
5 2712
pbmods
5,821 Expert 4TB
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.,
Expand|Select|Wrap|Line Numbers
  1. include 'file1.php'; // Defines 'function1'
  2.  
  3. $func = 'function1';
  4.  
  5. $func(...);
  6.  
  7. include 'file2.php'; // Defines 'function2'
  8.  
  9. $func = 'function2';
  10.  
  11. $func(...);
  12.  
  13.  
Jul 31 '07 #2
xhunter
42
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.
Jul 31 '07 #3
xhunter
42
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.
Jul 31 '07 #4
pbmods
5,821 Expert 4TB
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.
Jul 31 '07 #5
kovik
1,044 Expert 1GB
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.
Aug 1 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
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...
2
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...
3
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...
21
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...
3
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...
1
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. *************************************
7
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...
5
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)...
0
Airslash
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...

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.