Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

open php file

Posted on 2004-03-21
9
Medium Priority
?
276 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 500 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

730 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