Size of scripts

If you are wondering how much the size of your script matters to PHP, you need not - PHP's script parser is incredibly fast, able to read in 100,000 lines of code in about three seconds on an 800MHz computer. Naturally it is generally not smart to have 100,000 lines of code in a script - you should try to split them up, for ease of maintenance if nothing else.

PHP code execution also is not affected by large scripts, although naturally its execution time will vary depending on how complex your code is. Reading and changing variables is almost instantaneous, whereas reading from and writing to files is one of the slower operations.

Remember that if you use a PHP code cache, PHP's parser has no work to do at all, so script size becomes even more irrelevant.

 

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Summary >>

Previous chapter: PHP as a CGI or a module?

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.