The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
Sorry to be a nuisance.
Heres the deal.
General gist of question; get the HTML of a php file.
All I want to do is get the html of a parsed PHP file and echo it into some form of a textbox etc.
In psuedo code: -
the file = open file.php
html = gethtml(the file)
echo html;
So say if the PHP file had: -
property ?>
As part of its source code, the output I am looking for will whatever value is within property.
I.e.
The object's property is....chicken
Get what I mean?
Cheers for any help (In other words, I want to do bascially what the browser->view source function does)
Looks like I might have to take the long way round on this.
Cheers for the help Garin.
There might be some javascript to get the code or something. Gonna give that a check now.
I've found a viewsource function which brings up the sourcecode of the page effectively, I suppose that'll have to do!
Cheers!
Try it like this...
eval('?>' . $string . '
Doubt it'll fix it, but you'll probably get further than line 1. Eval expects to start out in a PHP code block so you need to close it immediately if theres html code first. The snippets in the notes try a different approach, they strip out all the ?> and convert all the html lines into echos, although they dont seem to work too well.
Parse error: parse error, unexpected T_STRING in /var/www/localhost/htdocs/project/clsGenFunctions.php(83) : eval()'d code on line 1
I keep on getting that error...
It might be worth noting that this is intaking a file and not a string.
I.e. $string = contents of 'file.php'
$string="?>\n\n";
ob_start();
eval("$string;");
$executed_code = ob_get_contents();
ob_end_clean();
echo $executed_code;
Only thing you can do really is break down the file you load in and see which bits it stumbles over and make the necessary adjustments as you go along.
I don't know what you're doing of course but if the page you want to load in and execute isn't dependent on any variables in the executing script. You could just open a socket and request the page directly and capture the output that way.
Also a nice quote in the comments,
"If eval() is the answer, you're almost certainly asking the wrong question." -- Rasmus Lerdorf, BDFL of PHP
It complains about stuff, I've tried some of the examples in the comments bit, but they don't seem to do much good either!
Any ideas?
Been googling for about an hour.
Might have to leave it for tomorrow.
If so, recheck the link in my previous post, and read the tip box and follow the link for info on how to redirect the output into a string rather than browser.
Am I any closer? :)
Probably wasn't making myself clear.
You know when you view a PHP page, then view it's source using the view-source thing. There is no PHP related stuff in there because it has been parsed by the server, correct?
What I want is the stuff that is in that view source window, so basically I want the parsed PHP code returned....
You want to execute code that is in a string (loaded in from a text file in this case)? If so, you want...
[URL]http://uk2.php.net/eval[/URL]
Sorry to be a nuisance.
Heres the deal.
General gist of question; get the HTML of a php file.
All I want to do is get the html of a parsed PHP file and echo it into some form of a textbox etc.
In psuedo code: -
the file = open file.php
html = gethtml(the file)
echo html;
So say if the PHP file had: -
property ?>
As part of its source code, the output I am looking for will whatever value is within property.
I.e.
The object's property is....chicken
Get what I mean?
Cheers for any help (In other words, I want to do bascially what the browser->view source function does)