Possible to define methods within eval or include?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gavagai123
Forum Newbie
Posts: 1
Joined: Mon May 19, 2008 5:42 am

Possible to define methods within eval or include?

Post by gavagai123 »

Hi,

Is it possible to define a method of the class from which an 'eval' or 'include' is called within that eval or include? (In php 4.) E.g. I want 'myfunction()' to be a method of 'myclass' in the following:

<?php

class myclass {
function myclass() {
eval("function myfunction() { echo \"TEST\"; }");
}
}

?>

Thanks,

Tom
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Possible to define methods within eval or include?

Post by VladSun »

I would advice you not to use eval() ...
What you are trying to achive in general?
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply