News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Moon's Blog:
PHP generated code tricks
June 21, 2010 @ 10:45:59

Brian Moon has posted a few tricks he's figured out in relation to generating dynamic PHP code (a questionable method for some) you can use elsewhere in your application.

Something that is great about PHP is that you can write code that generates more PHP code to be used later. Now, I am not saying this a best practice. I am sure it violates some rule in some book somewhere. But, sometimes you need to be a rule breaker.

He gives the example of pushing the contents of an array out to a cache file (since the settings rarely change) and then just include the ".php" file when they're needed. The PHP in the file is interpreted and, with the help of an autoloader, all of the values inside will be made available to the rest of the script. Comments on the post mention alternatives to his method like memcache, using var_export and the possibility of using JSON to store the information instead.

0 comments voice your opinion now!
dynamic code database cache autoload


blog comments powered by Disqus

Similar Posts

Query7.com: A Look At PHP 5.3 Frameworks - Symfony2

GotoTech.com: Developer Diary: Taming Doctrine’s 2000 Flushes

Jamroll.co.uk: Using Lighttpd to Dodge the Digg Effect

Gopal Vijayaraghavan's Blog: APC 3.1.2 Released!

The PHP.cc: PHP 5.5: Out-of-the-Box Bytecode Cache


Community Events











Don't see your event here?
Let us know!


security introduction opinion language hack composer podcast install hhvm package symfony2 application overview facebook performance database component framework unittest release

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework