Connecting Tech Pros Worldwide Help | Site Map

Add href= tag to echo

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 02:15 PM
Robertico
Guest
 
Posts: n/a
Default Add href= tag to echo

Is it possible to add a "href=" tag to an echo line.

Something like this:
echo "<b>$name</b>,<br>Sorry there's a problem sending your message. Please
try <a href="/mail.html">again</a>";

Robertico



  #2  
Old July 17th, 2005, 02:15 PM
Daniel Tryba
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

Robertico <Robertico@nospam.notvalid> wrote:[color=blue]
> Is it possible to add a "href=" tag to an echo line.
>
> Something like this:
> echo "<b>$name</b>,<br>Sorry there's a problem sending your message. Please
> try <a href="/mail.html">again</a>";[/color]

Yes, it's possible. But your single line of code is flawed. You should
really find out how strings work in PHP:
http://www.php.net/manual/en/language.types.string.php
(pay attention to escaping and the use of ' and ")
  #3  
Old July 17th, 2005, 02:15 PM
Robertico
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

Is this better ?

echo "<b>$name</b>,<br><br>Sorry there's a problem sending your
message.<br> Please try ";
echo "<a href='javascript:history.back(1);'>again</a>";

Robertico


  #4  
Old July 17th, 2005, 02:15 PM
Hilarion
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

> echo "<b>$name</b>,<br>Sorry there's a problem sending your message. Please[color=blue]
> try <a href="/mail.html">again</a>";[/color]


Yes. There are many ways. One of them is:

<html>
<?php
echo '<b>' . htmlspecialchars( $name ) . '</b>,<br />';
echo 'Sorry there's a problem sending your message. ';
echo 'Please <a href="/mail.html">try again</a>.';
?>
</html>

another:

<html>
<b><?php htmlspecialchars( $name ); ?></b>,<br />
Sorry there's a problem sending your message.
Please <a href="/mail.html">try again</a>.
</html>


Hilarion
  #5  
Old July 17th, 2005, 02:15 PM
Robertico
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

Thx.

I 'am learning php :-))


  #6  
Old July 17th, 2005, 02:15 PM
Daniel Tryba
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

Robertico <Robertico@nospam.notvalid> wrote:[color=blue]
> Is this better ?
>
> echo "<b>$name</b>,<br><br>Sorry there's a problem sending your
> message.<br> Please try ";
> echo "<a href='javascript:history.back(1);'>again</a>";[/color]

Yes :)

Though the javascript URL is a horrible pratice.
  #7  
Old July 17th, 2005, 02:15 PM
Robertico
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

> Though the javascript URL is a horrible pratice.

Always interested in better solutions :-)) Please add one !

Robertico


  #8  
Old July 17th, 2005, 02:15 PM
BKDotCom
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

BTW, the source of your original error was the the internal quotes.
if your string is surrounded by double quotes, it can't contain double
quotes (without escaping them - ie $string = "this \"is\" better";)
same goes with single quotes
$string = 'what\'s the deal';

unrelated: in my oppinion it's better to use single quotes

  #9  
Old July 17th, 2005, 02:15 PM
Daniel Tryba
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

Robertico <Robertico@nospam.notvalid> wrote:[color=blue][color=green]
>> Though the javascript URL is a horrible pratice.[/color]
>
> Always interested in better solutions :-)) Please add one ![/color]

Just like in your first post, a normal http url will always work. "Going
back" can have side effects (just see some recent discussions (just
generate a new form pre-populated with the data you just got)), there is
no guarantee that there is actually an URL to go back to (the action
could have been opened in a new tab/browser), javascript could have been
disabled (just look at all security advisories that suggest disabling
javascript as a (temporary) workaround).

  #10  
Old July 30th, 2005, 07:55 AM
richard
Guest
 
Posts: n/a
Default Re: Add href= tag to echo

On 2005-07-15, Robertico <Robertico@nospam.notvalid> wrote:[color=blue][color=green]
>> Though the javascript URL is a horrible pratice.[/color]
>
> Always interested in better solutions :-)) Please add one !
>[/color]

print "<a href=\"something\">Somewhere</a>";
print '<a href="somthing">'.$sData."</a>\n";

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.