Hi,

With PHP 7.3, the following was used to grab content from another website:

<?php include '';?>

It works in PHP 7.3, but I get a black page in PHP 7.4 or higher.

Any help would be appreciated.

Thanks,

Jim

Dani AI

Generated

Short summary tied to the thread: saw an include of an HTTPS URL work under PHP 7.3 and show a blank page under PHP 7.4; correctly pointed out using a fetch function instead of a remote include. The blank page is most often a configuration or error-reporting issue rather than a PHP bug. The items below explain what to check and safer alternatives.

Things to check (quick checklist)

Security note: enabling allow_url_include poses significant risk; do not enable it to execute arbitrary remote code unless the security implications are fully understood. The safer pattern is to fetch remote output and treat it as data, validate it, then render or process it.

Recommended Answers

All 2 Replies

Do this instead:

<?php echo file_get_contents('https://www.some-other-website.com/stuff.php'); ?>

or

<?php
    $output = file_get_contents('https://www.some-other-website.com/stuff.php');
    // ... Do something with the $output string that contains the HTML from stuff.php ...

include() is used when you need to include other local PHP libraries in your code. Those other PHP files get interpreted by PHP. Use file_get_contents() when you want to take whatever string is executed by PHP (HTML or otherwise) and spit it out.

Just following up. Did this work for you?

commented: Hi Dani - thansk so much for the follow up! Unfortunately neither worked. Did you have any other thoughts? Thanks Again! Jim +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.