Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Load a php file to get variable without loading the html?

I want to get a variable from a php file. I’ve read, that you can use include 'mypage.php'; and then use the variable. But if I do that it loads the visual part from the other file too (html and css from <style> tag).

Other methods are also apreciated.

Kind regards.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have the var $screen_name in file twitter/index.php and want to have it in create.php

Tried:

include 'twitter/index.php';
echo $screen_name;

>Solution :

If you include the PHP file, it will also do the output. But you can suppress it with output buffering.

ob_start();
include './mypage.php';
ob_end_clean();

echo $varFromMypage;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading