Link to home
Start Free TrialLog in
Avatar of enasni_mark
enasni_mark

asked on

open php file

hi,
i have recently made a script to check the whois records for a domain my user inputs.
i now want to make a page which will check if the domain has a whois record or not and so display whether the domain is available or not.
i want to do this by running the page whois.php which returns the whois record for the domain but i don't want to use include or require because they will just echo whatever whois.php returns.
i want to get the source of whois.php after the script has been run but not have it echoed.
is there a function to do this or do i need to find a way of opening "php.exe whois.php" and getting whatever that returns?
thanks in advance
mark
Avatar of dneff68
dneff68

Hello,

You can try using fopen() and pass the url rather than a filename.  You may however have some problems if you are passing parameters, you'll have to try.

I believe there is also a way to redirect the output buffer to a custom function.  You could then parse it and wipe out the buffer, or replace it.  I can't remember the functions to do this.  I'll find it and post unless somebody posts it before me.

-David
Avatar of enasni_mark

ASKER

i was thinking of using fopen() but i also need to use GET to state the domain name.
ASKER CERTIFIED SOLUTION
Avatar of dneff68
dneff68

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
how does the ob_start() function work? why do you have "callback" in ob_start?
"callback" is the name of the function you'll write to parse the results of your 'include'.  You can call it whatever you like, so long as your function name matches.  The function you write (in this case, 'callback') take a parameter that wil hold the buffer contents.  You can then parse that $buffer variable to see if 'whois' contains what you're looking for.

To make sure this doesn't get back to the client, you can also call ob_clean() when you're finished parsing.  Be sure that you don't already have content going back to the client that you don't want wiped out (such as echo's, or content outside <? ?>).

-David
that seems to be what i need but how can i use an include or a require with get fields?
i've just tried but i don't think you can send get fields with require or include
Ooo... that may be where my needs differed.  I was hitting a local PHP page and could just have global variables. The PHP documentation for 'include' does state that pamameters can be passed, but that you must make sure allow_url_fopen is set on.

I'll try this a bit more when I get the chance.  Take a look at the online php docs for include.

-David