Connecting Tech Pros Worldwide Help | Site Map

Add href= tag to echo

  #1  
Old July 17th, 2005, 03:15 PM
Robertico
Guest
 
Posts: n/a
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, 03:15 PM
Daniel Tryba
Guest
 
Posts: n/a

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, 03:15 PM
Robertico
Guest
 
Posts: n/a

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, 03:15 PM
Hilarion
Guest
 
Posts: n/a

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, 03:15 PM
Robertico
Guest
 
Posts: n/a

re: Add href= tag to echo


Thx.

I 'am learning php :-))


  #6  
Old July 17th, 2005, 03:15 PM
Daniel Tryba
Guest
 
Posts: n/a

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, 03:15 PM
Robertico
Guest
 
Posts: n/a

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, 03:15 PM
BKDotCom
Guest
 
Posts: n/a

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, 03:15 PM
Daniel Tryba
Guest
 
Posts: n/a

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, 08:55 AM
richard
Guest
 
Posts: n/a

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";

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
outtputting dynamic link in xml tag using php prashant answers 12 July 3rd, 2008 04:15 AM
How do i getElementById("a") and add a class to it, using JavaScript,halfway there? SM answers 7 June 27th, 2008 08:13 PM
script to generate an external link info@musiclanerecording.com answers 6 May 29th, 2007 03:55 PM
how to call a function when somebody click a link? yangsuli@gmail.com answers 11 November 6th, 2006 10:15 AM