Rackover Rackover - 8 months ago 31
PHP Question

PHP Get content of another php page

I've got a webpage that display this : http://i.imgur.com/QUkMoiC.jpg
Just plain text. And I need to include this in another php webpage, like

$string = include('');
echo $string;

so this can return "King crimson - Moonchild - Lyrics".
but this doesn't work.

How can I do ?


Include will evaluate what's inside the specified file (And run it as PHP). For example, if you had:

$str = 'King crimson - Moonchild - Lyrics';

You could include it, and then echo $str to get what you are looking for.

I think what you're looking for is file_get_contents():

$string = file_get_contents('');
echo $string;

From the docs:

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.