Reply to Re: why can't you use eval() to create a class definition?

Your name:

Reply:


Posted by Janwillem Borleffs on 05/28/05 00:06

lkrubner@geocities.com wrote:
> We are probably lucky that PHP doesn't allow this, but I'm curious
> about what the argument is against allowing this? Why did the
> inventors of PHP keep this from working? This same thing, using eval
> to create a class defintion, works in Javascript, demonstrating,
> perhaps, that Javascript is very flexible and you can do awful things
> with it.
>
> Anyway, the following code prints out "class does not exist".
>

Not when you use valid code:

$string = "class SendFormattedText { ";
$string .= "function boldText() { ";
$string .= " echo \"<b>The world is a good place</b>\";";
$string .= "}}";

eval($string);


But, do yourself a favor and forget that eval exists...


JW

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация