|
Posted by Chris F.A. Johnson on March 21, 2008, 5:02 pm
Please log in for more thread options
On 2008-03-21, Jonathan N. Little wrote:
> Geoff Cox wrote:
>> On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little"
>>
>>> A much simpler method would be a link randomizer.
>>>
>>> <?php
>>>
>>> $links = array('a.html','b.html','c.html','d.html');
>>> $last=count($links)-1;
>>> $link=$links[rand(0,$last)];
>>>
>>> echo "<a href=\"$link\">Mystery Tour</a>";
>>>
>>> ?>
>>
>> Thanks Joanathan,
>>
>> when I use the above I get
>>
>> Mystery Tour"; ?>
>>
>> I must be missing something?
>>
>
> 1) your server must support php
>
> 2) the page is named with a ".php" extension (normally for most server
> setups)
>
> 3) attention to the escaped quotes
>
> echo "<a href=\"$link\">Mystery Tour</a>";
> ^ ^
> or concatenate with single quotes
>
> echo '<a href="' . $link . '">Mystery Tour</a>';
Or use the safer and more portable printf instead of the
deprecated echo:
printf '<a href="%s">Mystery Tour</a>\n' "$link"
--
Chris F.A. Johnson <http://cfaj.freeshell.org> ===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
|