To get a string of "File execution results"

Source: Internet
Author: User
Tags php print
Gets the string containing the result of the file execution
To describe the problem, here is a simple model:
For example, there is a file a.php, the content is as follows:



You are welcome: Logout




There is another file b.php

$s =file_get_contents (' a.php ', 1);
?>


In b.php Although can read the contents of the file a.php, but not the content after execution, if you want to be able to explain the code in PHP, so that $s get the following results, what is the best way?


Welcome you: Zhang San logout


Share to:


------Solution--------------------
Straight require/include in.
------Solution--------------------
$s =file_get_contents (' http://localhost/a.php ');
------Solution--------------------
Include to replace the specific content you want
------Solution--------------------
There's a bracket missing.

Ob_start ();
Include ' a.php ';
$s = Ob_get_clean ();
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.