![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 | |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
![]() 1) Why can't I use '$this' since when $func() is executed it will be in foo's object context ? (So $this should be available ?!)
2) How can I avoid this problem ? (cause I really need to call a function from class foo) Quote:
__________________
I have nothing to advertise ... yet. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Oct 2003
Location: Command Central, West Palm Beach, Fl
Posts: 1,794
|
it's late for me, but isn't it
foo::internal();
__________________
I do stuff - aIm CS_Jay_D |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
foo::internal(); would work except for the fact that I really need $this because internal() normally use $this->properties...
I've oversimplified my example. Sorry. This would be more accurate : Quote:
I also tryed call_user_func_array(array($f, 'bar'), array()); instead of $f->bar without success Thanks for you help... specially at this hour.
__________________
I have nothing to advertise ... yet. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
What version of PHP are you using?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
php 5.3.0
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
I can't even do anonymous functions as none of my php versions are 5.3 or above.
Are you getting an error or is just not working? If error, what line is giving you the error? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Ok it's possible to do this :
Quote:
__________________
I have nothing to advertise ... yet. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
bump 8char
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
the guy
Industry Role:
Join Date: Apr 2005
Posts: 764
|
I'm not a programmer, just a sysadmin, but perhaps it relates to register_globals being disabled?
__________________
If you won't feel as good, I won't feel as cheap. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
can't help really as I'm on 5.2.x, so all this isn't available, but according to http://php.net/manual/en/migration53.incompatible.php
Quote:
scroll down to user comment by chris at NOSPAM dot panospheric dot com 23-Sep-2007 02:37 this looks like what you are trying to do? hope it helps
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | ||
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Quote:
Ultimately what I would like to do is something like this : Quote:
__________________
I have nothing to advertise ... yet. |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Industry Role:
Join Date: Oct 2007
Posts: 1,448
|
Then use: $response = exec($code);
And what's the reason for you complicating shit beyond belief?
__________________
xMarkPro -- Ultimate Blog Network Management Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 | |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Quote:
LOL it's complicated I'll give you that! but in my application users can inject their own code into my predefined objects. Lets say for overriding a behavior that doesn't fit their business rules ... thanks for your help.
__________________
I have nothing to advertise ... yet. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
So Fucking What
Industry Role:
Join Date: Jul 2006
Posts: 17,189
|
that's a tuffy ...
![]()
__________________
best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Here we go !
Thanks everyone for your help ! Code:
class foo{ public $msg; public function __call($method, $args){ if(isset($this->$method)){ $func = $this->$method; call_user_func_array($func, $args); } } public function create(){ $method = 'bar'; $this->msg = 'hello'; $parameters = '$param1, $param2'; $param1 = 'William'; $param2 = 'Phorrend'; $code = 'print ($obj->msg." $param1 $param2");'; $obj = $this; $fctStr = "return function($parameters) use(\$obj) { $code };"; $this->$method = eval($fctStr); $this->$method($param1, $param2); } } $foo = new foo(); $foo->create();
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |