Storing the HTML output from a local PHP file into a string using file_get_contents

前端 未结 4 724
囚心锁ツ
囚心锁ツ 2020-12-10 18:13

There is a header.php file and it contains some php codes that return HTML. I know I can use require, include to echo the results, but what I want to do is to store its proc

4条回答
  •  北海茫月
    2020-12-10 18:55

    If URL wrappers are enabled and you want the output of header.php (and you don't want to keep session state) you could use $headerHTML=file_get_contents('http://yourdomain.tld/path/to/header.php');, though why you would want to do such a thing eludes me. Are you sure you're not trying to do something that could easily be solved by using templates and caching?

提交回复
热议问题