473,325 Members | 2,805 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,325 software developers and data experts.

can $this be passed as a method parameter?


In a class, can $this be passed by reference or value?

function setDatabaseObject("MySql", $this) {
// some code here checks the name of the
// class of the object that is calling this method
}

For security, and to enforce naming conventions, I'd like for some of
my objects to only be callable from certain classes, but the only way
I can think for an object to get the name of the calling code is if I
had in the $this keyword.

Jul 17 '05 #1
2 1293
On 2005-02-04, lk******@geocities.com <lk******@geocities.com> wrote:

In a class, can $this be passed by reference or value?

function setDatabaseObject("MySql", $this) {
// some code here checks the name of the
// class of the object that is calling this method
}

For security, and to enforce naming conventions, I'd like for some of
my objects to only be callable from certain classes, but the only way
I can think for an object to get the name of the calling code is if I
had in the $this keyword.


in php5 you would mean something like this?

function foo($caller, $bar)
{
// do something with the reflection api i can find in the manual?
}

$class = new Class;
foo($class, "fubar");


--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #2
<lk******@geocities.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

In a class, can $this be passed by reference or value?

function setDatabaseObject("MySql", $this) {
// some code here checks the name of the
// class of the object that is calling this method
}

For security, and to enforce naming conventions, I'd like for some of
my objects to only be callable from certain classes, but the only way
I can think for an object to get the name of the calling code is if I
had in the $this keyword.


A situation for debug_backtrace(). Just keep stepping back until you find a
class name that's permitted.

http://www.php.net/debug_backtrace/
Jul 17 '05 #3

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

Similar topics

2
by: Marcin | last post by:
Hello! Is there any method to detect parameters values passed to called method? For example: public Guid ApplicationLogin(string userName, string password, int dbId)
8
by: Derrick | last post by:
I saw the ref param keyword relating to base types. Just checking, if I pass an object around to other class constructors, there will only be one instance of the object, correct? Thanks! ...
1
by: Jackie W | last post by:
Has .NET any XML-based validation framework or tool classes to validate parameters passed to an Web Service? I need only couple of types validation - is parameter passed to Web Service method...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: kplkumar | last post by:
I am trying to get the method and the parameters passed to that method from the stackTrace. My code is, private void GetExecutingMethodInfo() { StackTrace trace = new StackTrace(false); ...
18
by: Dave Booker | last post by:
I have a Thread making a callback to a Form function that alters Form data. Of course, the debugger is telling me, "Cross-thread operation not valid: Control 'FormTest' accessed from a thread other...
0
by: André | last post by:
Hi, I have still this unsolved problem, so i post it again. I hope someone replies and solves this or tells me it's impossible to do that this way ... My feeling is that it must work ... I...
52
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it...
83
by: Anonymous | last post by:
Came across some code summarized as follows: char const* MyClass::errToText(int err) const { switch (err) { case 0: return "No error"; case 1: return "Not enough"; case 2: return "Too...
28
by: Mike Hofer | last post by:
I've been maintaining some source code, and I've noticed some radical inconsistency in the code, particularly in the way that parameters are validated. I've noticed that this seems to have been...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.