Ahh, this'll be my last post for a bit, give the board some time to recuperate, lol I was just sandboxing with urlencode, but it's not working. Not sure what I'm doing wrong... I'm writing the code the same as in the documentation... <?php $apples = 'yes'; $oranges = 'no'; $queryString = '?apples=' . urlencode($apples) . '&' . 'oranges=' . urlencode($oranges); echo '<a href="localhost/'.$queryString.'">Test Link</a> '; ?> Code (markup):
yeah, straight from the chm file. I hardly changed anything... from the help file... <?php $query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar); echo '<a href="mycgi?' . htmlentities($query_string) . '">';?> PHP: Basically it does nothing... Nothing is encoded. The output string is exactly as it would be if I did nothing, lol.
hi, try this code: $apples = 'yes'; $oranges = 'no'; $queryString = '?apples=' . urlencode($apples) . '&' . 'oranges=' . urlencode($oranges); echo '<a href=./test.php'.$queryString.'>Test Link</a> ';
Okay - first off, a .chm-file is not the manual. PHP.net is the manual. The page you're looking for is here: http://no1.php.net/manual/en/function.urlencode.php Second, as others have informed you, urlencode only encodes things that needs to be encoded. Hence the $apples and $oranges example is completely idiotic, since the variables doesn't actually contain anything that needs encoding.
"Okay - first off, a .chm-file is not the manual." I don't think you're right about that. As far as I can tell the chm file is a downloadable version of the manual. Got it from here. http://php.net/download-docs.php Why they would have an example in their documentation that has NOTHING to do with doing what the function would do properly is beyond me, lol.
Aha. Downloaded from php.net - that's fine then Point is that .chm-files are usually Windows help-files, which may or may not be worth the look-up. Usually the concensus is "not". Hence why it's usually better to just go to the source online, and read through that, AND the comments - often the comments contain more information, better examples, and maybe, just maybe, just the right function or example to solve your own problem.