Link to home
Start Free TrialLog in
Avatar of James Williams
James WilliamsFlag for United States of America

asked on

PHp Fwrite Fopen Name file with URL

How can I get php to create a file then write to it using
the URL for the name.


http://example.com/hey/you/

and the output file name would be

heyyou.txt


I have been at this for a while now.

Thnk you in advance.
$fp=fopen("comm.txt",'ab');
fwrite($fp,$outputstring);
fclose($fp);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hawarden
hawarden
Flag of United States of America image

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
Avatar of James Williams

ASKER

Yes, I apologize if was unclear.  
The problem I am having is    Grabbing The actual URL of the page.
As the $url in not known for it is dynamic.        


Something like  
$url = $_GET["_$request"];  .
How do I dynamically set the $url


Thank you.   


Selvol
If you print out the contents of _GET with print_r, you should see a field that contains the full URL.

Off the top of my head, $_SERVER['QUERY_STRING'] might contain what you need. You can print it out to see. Sorry, I'm not near a web server at the moment to test it out right now.
Thank you.    I'll get it now.     


Regards.

$uri = $_SERVER['REQUEST_URI'];

echo $uri;

Open in new window