Jump to content

include


alin19

Recommended Posts

when you include a file, its just like copying and pasting the code from that other file into the parent file so, what you're proposing should work fine.

 

<?php //page2.php
$y = $x + 3; 
?>

 

<?php //parent page
$x = 2;
include('page2.php');
echo $x * $y; // result: 10

?>

Link to comment
https://forums.phpfreaks.com/topic/102301-include/#findComment-523849
Share on other sites

but i need the other way around, what can i do than?

 

i need a var declared in the first file to could be included in the second one;

 

//first

<?php

<form>

<input type=text name="form">

</form>

$x=$_POST['form'];

include(second.php);

?>

 

 

//second

<?php

echo "test";  //this isn't working

 

$y=$x;

echo $y;  //and this also isn't working

?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/102301-include/#findComment-523851
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.