-1

getting variable from another php-file from line

Hello Is it possible to get a value from another PHP file Reading variable from specific line Example

file1.php

<?php
echo 'my variable is';
//reading the variable from line 3
?>

file2.php

<?php
/*this  is line 1*/
/*this  is line 2*/
$var = 'hello world'; /*this  is line 3*/
?>
2
  • This might help you >> stackoverflow.com/questions/13135131/… Commented Feb 27, 2014 at 22:27
  • Is it possible to read from specific line the variable Commented Feb 27, 2014 at 22:32

2 Answers 2

1

Use include or require in file1.php :

<?php
include 'file2.php';
//require 'file2.php';
echo 'my variable is '.$var;
//reading the variable from line 3
?>
Sign up to request clarification or add additional context in comments.

Comments

0

you can include the file in the page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.