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.
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;
Advertisement
Answer
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;