Add href= tag to echo 
July 17th, 2005, 03:15 PM
| | | |
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 | 
July 17th, 2005, 03:15 PM
| | | | 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 ") | 
July 17th, 2005, 03:15 PM
| | | | 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 | 
July 17th, 2005, 03:15 PM
| | | | 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 | 
July 17th, 2005, 03:15 PM
| | | | re: Add href= tag to echo
Thx.
I 'am learning php :-)) | 
July 17th, 2005, 03:15 PM
| | | | 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. | 
July 17th, 2005, 03:15 PM
| | | | re: Add href= tag to echo
> Though the javascript URL is a horrible pratice.
Always interested in better solutions :-)) Please add one !
Robertico | 
July 17th, 2005, 03:15 PM
| | | | 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 | 
July 17th, 2005, 03:15 PM
| | | | 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). | 
July 30th, 2005, 08:55 AM
| | | | 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"; |  | | | | /bytes/about
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 225,662 network members.
|