You are here: Re: building url from variable « All PHP « IT news, forums, messages
Re: building url from variable

Posted by Susan on 11/07/07 02:21

Yes, I know that I was putting up a literal $var.

I am not sure of the syntax to make it a valid php statement.

On Tue, 06 Nov 2007 20:51:19 -0500, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

>Susan wrote:
>> I am trying to do the following:
>>
>> I want to assign a string to a variable then use that variable in an
>> HREF as follows:
>>
>> <html>
>> <head>
>> <title>Test Doc</title>
>> <meta http-equiv="Content-Type" content="text/html;
>> charset=iso-8859-1">
>> </head>
>>
>> <body>
>>
>> <?php
>> $var = "123.htm";
>> ?>
>> The variable $var has a value of:
>>
>> <?=$var?><br />
>>
>>
>> <a href="http://www.widgets.com/$var">click here </a>
>> </body>
>> </html>
>>
>> I print out the variable in the script and it is as it should be.
>> However, when you place your cursor over the "click here" on the
>> bottom of the page you see www.widgets.com/$var
>>
>> If I look at the source, I do not see the php portion of the script. I
>> am new to this and do not know if that is normal.
>>
>> Why won't the href statement utilize the value of the variable as
>> oppposed to the variable itself?
>>
>> Again, I am a beginner and any guidance would be much appreciated.
>>
>
>That's because you aren't echoing the variable in your href - in fact,
>you're not even in PHP code. When you're not in PHP code, $var is just
>the characters '$', 'v', 'a' and 'r'.
><a href="http://www.widgets.com/$var">click here </a>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация