473,604 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function name in a constant

Hi all!

$func = "echo";

This works fine, we all know.
but is there a possibility to get something like that working?

define (FUNC,'echo');

I know there are better ways to work around this problem, but is it
theoretically possible?

I even tried stuff like
define (FUNC,'echo');
constant('FUNC' )("xyz");

What I don't want to do is extracting the constants value to a variable
and then call the function in two steps.

I hope someone knows a solution


Jul 17 '05 #1
2 2652
On Wed, 24 Sep 2003 11:22:37 +0200, Kolja Engelmann
<dr************ *@t-online.de> wrote:
$func = "echo";
$func("xyz") ;

This works fine, we all know.
but is there a possibility to get something like that working?

define (FUNC,'echo');

That'd require macros, which PHP doesn't have.

Andy Hassall (an**@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2
Kolja Engelmann wrote on Wednesday 24 September 2003 02:22:
but is there a possibility to get something like that working?

define (FUNC,'echo');

I know there are better ways to work around this problem, but is it
theoretically possible?

Yes, if you use:
call_user_func( FUNC, "xyz");

Note that my understanding is that both your first example as well as my
suggested solution will work on user defined functions only; i.e. "echo"
should not work in either case.

Business Web Solutions
ActiveLink, LLC
Jul 17 '05 #3

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

Similar topics

by: Rudi Hansen | last post by:
I dont seem to be able to find the switch statement in Python. I would like to be able to do switch(var) case 1 : print "var = 1" case 2: print "var = 2"
by: Robert | last post by:
Hi all, class Homer { public: int dot(int) const {return 1;} ... } what's the meaning of const after function name?
by: Dalan | last post by:
I need some assistance or advise in composing code for a global function module or a related one for populating values in text boxes on reports and forms with a name, actually several different names. There are over 50 fields in the database requiring name updates and I need to do this several times. And I don't want to use a table/form to perform this task. Here is a bit more information. Yes, I have done the changing of the values in...
by: baumann | last post by:
hi all, typedef int (*pfunc)(int , int); pfunc a_func; i know it's ok, but how can define a_func without typedef statement? thanks .
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
by: ramu | last post by:
Can anyone tell me the advantages of using function pointers? Thanks in advance.
by: Yelena Varshal via AccessMonster.com | last post by:
Hello, I have a problem with one of msaccess.exe API calls that work on my desctop but does not work on the laptop from within MS ACCESS. There is a lot of differences between 2 computers including one running Office 2000 and another running Office 2003. This code was created by a previous developer. I need to find the description and parameters of the API calls. I found the article ...
by: Joyti | last post by:
Hi, Need help in solving issue. I m having one function: int alllowReset(TRAN & tranP) { if( tranP->name == "PQRS" || ... ..
by: =?Utf-8?B?Sm9obiBTaW1wc29u?= | last post by:
Like every developer, I've got tons of error trapping code that hard code the name of the function or sub name so I can error log it. It seems from other discussions that the only way to get the function or subprocedure name is to either hard code it or to use a Constant to store it and reference the Constant in each Catch statement. There are no properties that return the function/sub name. Has anyone found a way thru reflection to get...
by: mohanprasadgutta | last post by:
hello everyone, i have to write a program which will take a command line arguement which is nothing but a constant name. in the program i am trying to print out the value corresponding to the constant name provided. i am aware of converting a string to a variable name as follows. my $name = "mohan"; my $var = "name"; my $new = $$name; print "your name is : " . $name . "\n"; But here i have to get the constant value corresponding to...
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,...
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...
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,...
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...
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();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.