PHP file_get_contents with php intact?

后端 未结 6 1473
后悔当初
后悔当初 2021-02-15 16:30

As opposed to using an include, which executes the included php in the file...is it possible to save the contents of a php file to a variable - but with the php still intact and

6条回答
  •  天命终不由人
    2021-02-15 17:12

    If you're developing in 5.3 it's much easier but even on 5.2 you can use what's called an anonymous function to do this.

    An anonymous function will allow you to pass code around as a variable. To load this code from a file you may have to file_get_bytes into a string, eval that, then put in in a variable but you get the point I hope.

    5.3: Anonymous functions

    5.2: create_function

提交回复
热议问题