1

I have a PHP page Read.php that echoes the contents of another php file, test.php.test.php contains some php codes but these codes are not processed in Read.php. They are copied as they are.

Read.php

<?php

    $text = 1;
    if ($text == 1){
        $file = file_get_Contents("test.php");
        echo $file;
    }
?>

test.php

<html>
    <body>
        <p>Text
            <?php echo "Manish";  echo $text;>
        </p>
    </body>
</html>

Source code of Read.php

<html>
    <body>
        <p>Text
            <?php echo "Manish";  echo $text;>
        </p>
    </body>
</html>

How do I make this php code process?

3 Answers 3

2
<?php

    $text = 1;
    if ($text == 1){
        include('test.php');
    }
?>
Sign up to request clarification or add additional context in comments.

Comments

2

Read.php

<?php

$text = 1;
if($text == 1){
  include 'test.php';
}

?>

Comments

1

Retrieve it from the web server (http://...) instead of from the filesystem. PHP is only processed if the web server processes it.

1 Comment

Well, technically include()ing or require()ing the file would also result in a similar behavior here.

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.