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 Quote 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? Quote 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(); ?> Quote 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! Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.