page where i put my iframe has the $variable = 1 for example and then with iframe i include another file that needs to use that variable. Can it use it?
1. page.php with the variable $variable=1 it also has a iframe pointing to page2.php 2. page2.php has a javascript that uses $variable, but I don't think it can access it, with the php include command it worked fine but not with iframe... Should it work?
If both pages are yours you should be able to do this yes. I'm not too familiar with JavaScript but I am fairly sure you can use JavaScript to change data in an iframe. If you do own both pages, then you can use MySQL or a simple file system to retrieve the value from independently, and then echo it in the correct place in page2.php for the javascript
You are right, the iframe uses 2 http requests. You would have to load page2.php?variable=1 in the iframe
You cant share php variables that are not loaded in same "request" you need to pass to page2.php variables through URL params. iframe is just a another URL inside HTML page. it is not file inside page1.php so you cant share variables directly
Just like conductr said The iframe must be like: <iframe src="page1.php?variable= <?php echo $variable; ?> &variable2= <?php echo $variable2; ?> "></iframe> PHP: And the page1.php: The value of the variable 1 is : <?php echo $_GET["variable"]; ?> The value of the variable 2 is : <?php echo $_GET["variable2"]; ?> PHP: