Solved

open php file

Posted on 2004-03-21
9
265 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:enasni_mark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 

Expert Comment

by:dneff68
ID: 10644392
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
0
 

Author Comment

by:enasni_mark
ID: 10644516
i was thinking of using fopen() but i also need to use GET to state the domain name.
0
 

Accepted Solution

by:
dneff68 earned 125 total points
ID: 10644578
Here's how I did it.  You can disable the buffer output and redirect it to a function you write, then kill ther buffer.

In my case, I was trying to export a dynamically generated page to a static HTML page, also without outputting the contents back to the client.  I have a callback($buffer) function that handles what would normally be pumped back to the client, and my exportPage function that does a require on the file I'm interested in.  The ob_end_flush() returns things to normal.

function callback($buffer)
{
  // do whatever you want with the buffer contents
}

ob_start("callback");
exportPage($file);  // does a require on $file
ob_end_flush();

Hope this helps.

-David
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:enasni_mark
ID: 10644615
how does the ob_start() function work? why do you have "callback" in ob_start?
0
 

Expert Comment

by:dneff68
ID: 10644645
"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
0
 

Author Comment

by:enasni_mark
ID: 10644658
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
0
 

Expert Comment

by:dneff68
ID: 10645266
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
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question