You can use __halt_compiler() , the purpose of which, as the name implies, is to stop the compiler with the goal of embedding data in the rest of the file.
Basic example:
<?php // Do something boring here $data = file_get_contents(__FILE__, FALSE, NULL, __COMPILER_HALT_OFFSET__); $obj = json_decode($data, TRUE); echo $obj['message']; __halt_compiler(); {"status":"example", "message":"hello, __halt_compiler!"}
The output, as you would expect, is hello, __halt_compiler!
source share