GetDotted Domains

Viewing Thread:
"PHP related post (again, sorry)"

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.

Mon 07/02/05 at 21:41
Regular
Posts: 10,364
Argh, I know I keep bringing up these posts.

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)
Tue 08/02/05 at 11:08
Regular
Posts: 10,364
Hmmmm.

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!
Mon 07/02/05 at 23:38
Regular
"Devil in disguise"
Posts: 3,151
If your file is something like





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 ?>
Mon 07/02/05 at 23:12
Regular
Posts: 10,364


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'
Mon 07/02/05 at 23:01
Regular
"Devil in disguise"
Posts: 3,151
It is a bit more complicated than it seems, simple version of it..

$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
Mon 07/02/05 at 22:47
Regular
Posts: 10,364
Argh, I have a feeling you are right, but I still just cannot get it to fully work.

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.
Mon 07/02/05 at 22:23
Regular
"Devil in disguise"
Posts: 3,151
So eval nearly does what you want but it outputs the "parsed php" directly to browser and you want to capture the output into a string?

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? :)
Mon 07/02/05 at 22:13
Regular
Posts: 10,364
Ah nope.

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....
Mon 07/02/05 at 22:06
Regular
"Devil in disguise"
Posts: 3,151
Hm, not sure I understand what you want but...

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]
Mon 07/02/05 at 21:41
Regular
Posts: 10,364
Argh, I know I keep bringing up these posts.

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)

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thank you very much for your help!
Top service for free - excellent - thank you very much for your help.
Best Provider
The best provider I know of, never a problem, recommend highly
Paul

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.