This is an odd issue I ran into that adds a number (so far the number 1) to where the included data goes and positions the included data earlier in the code. I initially thought it might be some code on the TEXT.php that was causing the issue, but I simplified the two files until I got to a point where I have no idea what is causing the issue. The below code should result in the issue, despite how simple it is. While I can work around the issue, I would like to understand why I get a number and the included data moves.
The main code just references the Text.php in three ways.
- First way is how I normally include php files.
- Second is with some text before the echoed value that includes text, this results in a number appearing where the text should be and the text showing up earlier in the code.
- Third is just the echoed value that includes text, this results in a number appearing where the text should be and no text.
All that exists on the Text.php is sample text.
Sample Text
Below is the main code.
<?php
$Value = include 'Text.php';
include 'Text.php';
echo "<br>";
echo "Example: " .$Value;
echo "<br>";
echo $Value;
?>
The main code results in the following when viewed on a browser;
Sample TextSample Text
Example: 1
1
Instead of:
Sample Text
Example: Sample Text
Sample Text
I would appreciate if someone that knows code better than I could explain why this happens this way. Thank you for your time.