This may seem odd but I’m simply trying to put a url together.
The first part ($first) I get from user input using strrpos() and substr() with “/”.
The exact file I want to get to is fixed ($second) so all I think I need to do is this:
$first = "http://www.somedomain.de/somepath/";
$second = "thexml.xml";
$url = $first.$second;
BUT: Although I use trim() on every part there still is some whitespace between the two parts when I print $url.
When I try to navigate to $url the whitespace is replaced by a “%”.
The path itself is correct, when I get rid of the whitespace/ % manually in my browser’s adress bar.
I also tried putting the two strings together with an array and implode() but the output stays the same.
What am I doing wrong?
Update from Lisa
ok, so I printed $first and $second separately and there are no whitespaces. it seems to be appearing when I concatenate them and exactly where the two strings are put together.
Any other ideas?
ok, so I printed $first and $second separately and there are no whitespaces. it seems to be appearing when I concatenate them and exactly where the two strings are put together.
Any other ideas?
Most likely, the code you’re editing or the inputs (user, database, etc.) is not what you expect. Try trimming down (no pun intended) the code to a minimal example. For example, go from
to
step-by-step to find the mistake.