Reputation: 362
I have a page that uses another page via the include() function. The page that requests and uses this external page has some html embeded as well as some output using the echo function. Here is an example of what I am referring to.
page Apple.php contains:
<html>
<head></head>
<body>
<h1>I have some content here.</h1>
<div id="format" style=" width:20px; height:20px;"><?php include("Orange.php") ?></div>
<h2>Some more content here.</h2>
</body>
<html>
page Orange.php contains:
<?php
$astringA='blue';
$astringB='berry';
include("someExternalPage.php");
echo "fruit is ".$astringA.$astringB.$externalVariable;
?>
Whenever the Apple.php is viewed in browser, only the top part of its body is shown(the part above the include function) and everything below the div box is lost and filled with whitespace. In addition the included file ignores all style that the div box has. The same is true for the Orange.php; all output below the include() function is lost. How can I fix this so that the included file will conform to the style I want for it and also to continue to output the rest of the content on the pages?
I also notice that even if I try outputing the rest of the page through php such as echo ">h2>Some more content here."; (I deliberately inverted the first ">" in the line above so that I illustrate the code here) the included still takes precedence over the current page and thus the output is never shown.
Upvotes: 0
Views: 189
Reputation: 3025
Looks like you're missing a semicolon after the include in Apple.php. Can we see the output when you try to load Orange.php
? It's helpful to see exactly where the flow is breaking.
Upvotes: 0
Reputation: 825
If someExternalPage.php is actually an external file (ie you are including a file such as http://example.com/test.php) you may need to check that you have enabled allow_url_include in your php.ini
Alternatively, please make sure someExternalPage.php exists.
Upvotes: 0
Reputation: 40
There's something wrong either with someExternalPage.php or $externalVariable.
Upvotes: 0
Reputation: 12244
Smells like you have a hidden fatal error here.
Try using error_reporting(E_ALL) and run the page to see if you have an error...
Upvotes: 3