Alex Alex - 6 days ago 5
PHP Question

Getting %3F on URLs

I'm using simplehtmldom and I'm trying to get all links from a website. This is my script:

include('simplehtmldom/simple_html_dom.php');

// get DOM from URL or file
$html = file_get_html('http://example.com/urls/');

// find all a tags
foreach($html->find('a') as $e)
echo $e->href . "\n";


What I'm getting is the full list of urls but some of them end with a %3F where there sould be a string. Something like:

http://example.com/urls/%3F


Instead of:

http://example.com/urls/foo


I've done some research and it seems the fix needs to be done on the Apache server bu tI don't have access to it, is there anything I could do to fix it?

Answer

Just decode incoming url like this :

echo urldecode($e->href)."\n";

It will give the decoded url for string.

Comments