I have a php script, which can be run independently from the command line, so it's first line is #!/usr/bin/env php
. However, I also have another script, which can automatically run the first one. It does this by calling include 'example.php'
, which works, except that it outputs the first line as text.
How do I make include skip the first line? So far the only options I could think of were to wrap the whole thing in an output buffer and then trim the first line, but that has a whole host of problems with it. Alternatives such as using exec()
to simulate running the second script from the command line, or reading in the whole file and evaluating it with eval()
, both seem like pretty horrible solutions.
Is there any way to tell php, "include this file but don't output the first line"?
I am aware I can just remove the shebang and run the script with php script.php
whenever I need to use it, which is ok in this specific case, but I would still like to know if there is an alternative, general way to make include ignore the first (or first X) lines.