RU beehive logo ITEC dept promo banner
ITEC 325
2018fall
ibarland

php in multiple files
require_once

splitting into multiple files

video: require_once (18m47s)

We can take blend.php (src), and separate the code from the test-cases: utils.php (src), and separately utils-test.php (src). The directive require-once is a run-time instruction which just goes to the require'd file and (effectively) splices it into the current file, and continues evaluating line-by-line. (So it's reminiscent of java's import, but require-once significantly more simple-minded. Beware trampling on identifiers, and it's poor practice to have any dangling tags / code in the require'd file.)

This also lets us separate a program that uses blend from the test cases: some-web-page.php (src), and some-web-page.php (output).



logo for creative commons by-attribution license
This page licensed CC-BY 4.0 Ian Barland
Page last generated 2018.Sep.05 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.