-4

I have a File named 1.php and I have another file named index.php

I use

include('index.php');

for including index data. Is there a way i can pass data to index.php file?

6
  • 1
    All the global variables defined before include are also available in the included PHP code. Commented Feb 14, 2020 at 17:37
  • is index.php inside 1.php? Commented Feb 14, 2020 at 17:38
  • Are you trying to pass data from 1.php to index.php or the other way round? Commented Feb 14, 2020 at 17:39
  • If you want to send data from one page to another page I would recommend looking to POST variables in PHP Commented Feb 14, 2020 at 17:39
  • Yes index.php is in 1.php file @EbrahimMohammed Commented Feb 14, 2020 at 17:39

1 Answer 1

2

if index.php is inside 1.php , you can do that:

1.php:

<?php $variable = "hello"; 
      include('index.php');
?>

index.php

<?php 
echo $variable; //this will output hello.
?>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.