473,671 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the source code of a method/function call?

Currently, I use this call

traceVariable( $_SERVER['PHP_SELF'], '$_SERVER["PHP_SELF"]' );

to pass a variable by reference to 'traceVariable' and by value a
description string.

Since the description string is very likely to be identical to the
source code (string) of the first parameter, I'd like to write this:

traceVariable( $_SERVER['PHP_SELF'] );

Any ideas, how to get the literal expression (source) of a parameter,
which got passed to a method/function?

Dec 16 '06 #1
4 2636
On 16 Dec 2006 15:23:19 -0800, "seaside" <se********@mac .comwrote:
>Currently, I use this call

traceVariable( $_SERVER['PHP_SELF'], '$_SERVER["PHP_SELF"]' );

to pass a variable by reference to 'traceVariable' and by value a
description string.

Since the description string is very likely to be identical to the
source code (string) of the first parameter, I'd like to write this:

traceVariable( $_SERVER['PHP_SELF'] );

Any ideas, how to get the literal expression (source) of a parameter,
which got passed to a method/function?
See the thread "Easy question, return variable name" from just 2 days ago.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 16 '06 #2

Andy Hassall schrieb:
On 16 Dec 2006 15:23:19 -0800, "seaside" <se********@mac .comwrote:
Since the description string is very likely to be identical to the
source code (string) of the first parameter, I'd like to write this:

traceVariable( $_SERVER['PHP_SELF'] );

Any ideas, how to get the literal expression (source) of a parameter,
which got passed to a method/function?

See the thread "Easy question, return variable name" from just 2 days ago.
Ok, no standard method available. Then, I'll use backtrace to construct
'something'.

Dec 16 '06 #3
You can use the eval function to go the other way around (not tested):

function traceVariable($ name)
{echo $name . ' = ' . var_export(eval ('return ' . $name), TRUE);}

You'd call it with traceVariable(' $_SERVER[\'PHP_SELF\']');
seaside wrote:
Andy Hassall schrieb:
>On 16 Dec 2006 15:23:19 -0800, "seaside" <se********@mac .comwrote:
>>Since the description string is very likely to be identical to the
source code (string) of the first parameter, I'd like to write this:

traceVariable( $_SERVER['PHP_SELF'] );

Any ideas, how to get the literal expression (source) of a parameter,
which got passed to a method/function?
See the thread "Easy question, return variable name" from just 2 days ago.

Ok, no standard method available. Then, I'll use backtrace to construct
'something'.
Dec 17 '06 #4

Dikkie Dik schrieb:
You can use the eval function to go the other way around (not tested):

function traceVariable($ name)
{echo $name . ' = ' . var_export(eval ('return ' . $name), TRUE);}

You'd call it with traceVariable(' $_SERVER[\'PHP_SELF\']');
Hey, nice idea!

If PHP had a preprocessor, I could even prepare a #define() macro,
which
passes the passed literla-string and its expression along.
Unfortunately, I don't
know of any.

Dec 18 '06 #5

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

Similar topics

29
2270
by: Bill Marsden | last post by:
Hi. I am an under-graduate currently studying Open Source (Linux) vs Closed Source and Collaboration within the IT Community. I am fairly new to Javascript and I have written a "Lottery Program" which essentially picks 6 numbers at random and puts them in sequence. Would anyone would be interested in modifying the code below to a). Check for bugs b). Make the program more efficient
7
2340
by: Jean-Marc Blaise | last post by:
Hi, The dev center calls sqlj.DB2_UPDATEJARINFO ('JMARC.JMB','JMB','file:JMB.sqlj') to update the sqlj routine source. I tried in CLP from the directory containing jar and sqlj files (Windows 8.2 FP9): db2 connect to sample db2 call sqlj.DB2_UPDATEJARINFO ('JMARC.JMB','JMB','file:JMB.sqlj')
6
16438
by: Xing Xu | last post by:
Hi guiders, sorry , since I don't know which group suit for this question,I just post this question at these group. As we know , we can get the run-time call graph by some proved tools . now I have a problem about the extract call graph from statice C source code , not from binary. I have try to use cscope and write some perl script for it .
65
12572
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second method was a piece of C code which turned out to be incorrect and incomplete but by modifieing it would still be usuable. The first method was this piece of text:
8
2236
by: Alvo von Cossel I | last post by:
hey everybody, I have written a great browser but it is missing a feature (quite a lot actually, but forget about them for now). that feature just so happens to be the View > Source function. for those of you who don't what i mean, it is when you click a button in the view menu that says Page source (in Netscape) and source (in Internet Explorer). if you click it, notepad opens. in that window is the html for the page. anyway, does...
2
2240
by: Maellic | last post by:
Hi, I'm currently updating a website written with ASP.NET. The original programmer is overseas, there is no documentation, and files are all over the place. Here is a code snippet from one of the .vb file used by the application (the entire code of the file is at the end of the post): If EmissionsWebBLL.Security.ValidateLogin(txtUserName.Text,
2
2750
by: Dale Sampson | last post by:
My app uses an ODBC connection for a .mdb file. I want the app to create the source if it does not already exist (I copy a blank .mdb file to the users data store if it doesn't exist). I see how to do this using SQLConfigDataSource() and that works ok. Thing is, how to handle if the source already exists. Is there a way to check & see if the source already exists? Alternately, if it does exist & I call SQLConfigDataSource() does it...
4
1531
by: Pyenos | last post by:
#!/usr/bin/python #################################################### # answers.py --- A simple answer bot # Copyright (C) 2006 Logan Lee # # MESSAGE: # # This program is a simple text-console program #+that asks for a problem and its solution then
6
1384
by: Paul Wilson | last post by:
Hi all, I'd like to be able to do the following to a python source file programmatically: * Read in a source file * Add/Remove/Edit Classes, methods, functions * Add/Remove/Edit Decorators * List the Classes * List the imported modules * List the functions
0
8476
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8821
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
8598
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
8670
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
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...
0
5696
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();...
0
4225
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...
0
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2812
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

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.