envexlabs Posted April 17, 2009 Share Posted April 17, 2009 Hello, I have a modal window that appears, but it will only accept html files. No big deal, so i thought. Is it possible to write a function that will render out a php file behind the scenes and grab all it's contents. ie. script.php <?php echo 'This Works'; If i were to use fopen or get_file_contents nothing would show up. I would like php to do it's magic and return "This Works". Any ideas? Thanks, envex (matt) Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/ Share on other sites More sharing options...
The Little Guy Posted April 17, 2009 Share Posted April 17, 2009 Like this: http://beta.phpsnips.com/snippet.php?id=21 (read_file.php) Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812619 Share on other sites More sharing options...
envexlabs Posted April 17, 2009 Author Share Posted April 17, 2009 Hey, Nope, that doesn't seem to work. Thanks though. Looks like i may have to use xhr or a json request :S Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812621 Share on other sites More sharing options...
laffin Posted April 17, 2009 Share Posted April 17, 2009 check to see if yer php/apache installation suppoerts path info if it does just call the page as http://site.com/script.php/output.html Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812642 Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 What you're looking for is eval. http://us3.php.net/eval Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812650 Share on other sites More sharing options...
laffin Posted April 17, 2009 Share Posted April 17, 2009 how would eval help when the file doesnt have the extension of php, but html? Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812664 Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 Read the file using fopen (http://php.net/fopen) and fread(http://php.net/fread) in to $file_str, and... eval($file_str) Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812667 Share on other sites More sharing options...
envexlabs Posted April 17, 2009 Author Share Posted April 17, 2009 What you're looking for is eval. http://us3.php.net/eval I don't think it's working, i'm getting: Parse error: syntax error, unexpected '<' in /nfs/c03/h04/mnt/57152/domains/wheresyourstore.com/html/test.php(5) : eval()'d code on line 1 The file i'm referencing is reference.php my modal window will grab reference.php, but it won't parse any of the php because of the way it deals with javascript loading the content. Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812671 Share on other sites More sharing options...
soak Posted April 17, 2009 Share Posted April 17, 2009 The server should be dealing with php parsing. Try viewing reference.php directly in your browser. Is possible it has a syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812674 Share on other sites More sharing options...
keeB Posted April 17, 2009 Share Posted April 17, 2009 Well, shit. I was expecting the PHP file you uploaded to be purely php. In this case it has a mix of both? Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812677 Share on other sites More sharing options...
envexlabs Posted April 17, 2009 Author Share Posted April 17, 2009 Well, shit. I was expecting the PHP file you uploaded to be purely php. In this case it has a mix of both? Yeah, sorry it's been a long day of back and forth. The old brain is a bit fried. The reference file has no syntax errors, when i view it by itself it renders everything fine. This stupid modal box is causing a major headache, and of course it's on a friday Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-812687 Share on other sites More sharing options...
envexlabs Posted April 20, 2009 Author Share Posted April 20, 2009 monday morning bump. Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-814504 Share on other sites More sharing options...
keeB Posted April 22, 2009 Share Posted April 22, 2009 I suppose you should use http://php.net/include Makes sense doesn't it? Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-816100 Share on other sites More sharing options...
laffin Posted April 22, 2009 Share Posted April 22, 2009 I wud check 1 of two things 1) if u have path_info enabled (Apache web server only) or 2) read up on .htaccess and redirect the .html type extension to the php file. this way it bypasses yer modal box wors Quote Link to comment https://forums.phpfreaks.com/topic/154548-parsing-a-php-file-and-then-grabbing-its-contents/#findComment-816167 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.