robcrozier Posted November 20, 2008 Share Posted November 20, 2008 Hi, i'm trying to read the contents of a PHP file from another PHP file and then save only the raw text that would be outputted on the browser. So for example if i have a php file that looks like: <?php echo "Some text"; ?> I want to scan this PHP file and only retreive the "Some text" bit. I will then do some processing with this. I can already scan a HTML file and then strip all HTML tags to retreive the raw site text, however PHP is giving me a headache. Can anyone suggest how i would go about this? Cheers Link to comment https://forums.phpfreaks.com/topic/133518-read-content-from-a-php-file/ Share on other sites More sharing options...
gevans Posted November 20, 2008 Share Posted November 20, 2008 wouldn't it be easier to use; return "Some text"; and assign that to a value in the file that calls it? Link to comment https://forums.phpfreaks.com/topic/133518-read-content-from-a-php-file/#findComment-694443 Share on other sites More sharing options...
flyhoney Posted November 20, 2008 Share Posted November 20, 2008 <?php ob_start(); include 'file_that_echos_stuff'; // $output holds all the data echo'd in file_that_echos_stuff $output = ob_get_contents(); ?> Link to comment https://forums.phpfreaks.com/topic/133518-read-content-from-a-php-file/#findComment-694445 Share on other sites More sharing options...
npsari Posted November 20, 2008 Share Posted November 20, 2008 This link may be what you are looking for http://www.zortin.com/scripts/show/?id=294 But it is locked! Link to comment https://forums.phpfreaks.com/topic/133518-read-content-from-a-php-file/#findComment-694543 Share on other sites More sharing options...
premiso Posted November 20, 2008 Share Posted November 20, 2008 Another way is call the file using the url. <?php $file = file_get_contents("http://www.yoursite.com/filetogetcontents.php"); echo $file; ?> Should print out "Some text" given that the above URL exists. Link to comment https://forums.phpfreaks.com/topic/133518-read-content-from-a-php-file/#findComment-694550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.