Posted by Erwin Moller on 01/12/07 09:06
TMN wrote:
> Hi All
>
> I am new to PHP and I do not understand why the following works ??
>
> $file=urlencode("displayIncidents.php");
> echo "<a href=statistics.php?fileName=$file&delete=true>Delete
> Incident</a><br />";
>
> When this link is selected the statistics.php simply includes the file
> that passed to it - but why does it find the file and not try to load
> the literal 'fileName=$file&delete=true' (that obviously does not
> exist) ?
Hi,
We cannot say what statistics.php will do with the contents in the url
because you didn't show any code from that file.
But what you do here is simply creating an URL.
urlencode takes a string and transforms it to a form that can be passed
through a url, as you did.
Nothing more nothing less.
So what happens is:
1) your variable $file contains 'displayIncidents.php'
2) you echo:
<a href=statistics.php?fileName=$file&delete=true>Delete Incident</a><br/>
where $file gets replaced by the value in $file, so you get:
<a href=statistics.php?fileName=displayIncidents.php&delete=true>
Delete Incident</a><br/>
This happens because you put a variablename into "", it gets replaced.
If you use '' this will not happen.
consider the following code:
$myvar = "John";
echo "Hi $myVar";
// will produce: Hi John
Regards,
Erwin Moller
>
> thanks
> Tim
[Back to original message]
|