Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1675 > unrolled thread
| Started by | "Mentalguy2k8" <Mentalguy2k8@gmail.com> |
|---|---|
| First post | 2011-05-19 23:31 +0100 |
| Last post | 2011-05-20 17:21 +0100 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.php
How to "quote code" in PHP? "Mentalguy2k8" <Mentalguy2k8@gmail.com> - 2011-05-19 23:31 +0100
Re: How to "quote code" in PHP? Jeff North <jnorthau@yahoo.com.au> - 2011-05-20 10:47 +1000
Re: How to "quote code" in PHP? Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-19 21:47 -0400
Re: How to "quote code" in PHP? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-05-20 09:34 +0200
Re: How to "quote code" in PHP? "Mentalguy2k8" <Mentalguy2k8@gmail.com> - 2011-05-20 09:44 +0100
Re: How to "quote code" in PHP? Michael Fesser <netizen@gmx.de> - 2011-05-20 10:54 +0200
Re: How to "quote code" in PHP? Jeff North <jnorthau@yahoo.com.au> - 2011-05-20 20:21 +1000
Re: How to "quote code" in PHP? "Mentalguy2k8" <Mentalguy2k8@gmail.com> - 2011-05-20 17:21 +0100
| From | "Mentalguy2k8" <Mentalguy2k8@gmail.com> |
|---|---|
| Date | 2011-05-19 23:31 +0100 |
| Subject | How to "quote code" in PHP? |
| Message-ID | <ir45oo$mik$1@dont-email.me> |
I'm trying to put together a little page with a form, so that users can "translate" any URL into the correct format for posting on a forum. For instance, they want to share a link and type in "www.google.com" (without quotes) and the form turns it into "<a href="www.google.com"></a>" (without the beginning and end quotes) and displays that as text, so that they can copy/paste it into the forum post box. It will also include an image-posting version so that it adds the "<img src" etc to an image URL. How do I "quote" the result so that it displays as plain text rather than a mess? All I'm getting is a mess of blue code.
[toc] | [next] | [standalone]
| From | Jeff North <jnorthau@yahoo.com.au> |
|---|---|
| Date | 2011-05-20 10:47 +1000 |
| Message-ID | <etdbt6drc7pnku8602e0vud6u526irjkmu@4ax.com> |
| In reply to | #1675 |
On Thu, 19 May 2011 23:31:47 +0100, in comp.lang.php "Mentalguy2k8" <Mentalguy2k8@gmail.com> <ir45oo$mik$1@dont-email.me> wrote: >| I'm trying to put together a little page with a form, so that users can >| "translate" any URL into the correct format for posting on a forum. >| >| For instance, they want to share a link and type in "www.google.com" >| (without quotes) and the form turns it into "<a href="www.google.com"></a>" >| (without the beginning and end quotes) and displays that as text, so that >| they can copy/paste it into the forum post box. It will also include an >| image-posting version so that it adds the "<img src" etc to an image URL. >| >| How do I "quote" the result so that it displays as plain text rather than a >| mess? All I'm getting is a mess of blue code. A "mess of blue code" could mean that you are not appending the closing </a>. To display the text you need to convert < to < and > to > so your code would look like: <a href="www.google.com"></a> Have a look at htmlentities http://au.php.net/manual/en/function.htmlentities.php
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-05-19 21:47 -0400 |
| Message-ID | <ir4h82$gj0$3@dont-email.me> |
| In reply to | #1675 |
On 5/19/2011 6:31 PM, Mentalguy2k8 wrote: > I'm trying to put together a little page with a form, so that users can > "translate" any URL into the correct format for posting on a forum. > > For instance, they want to share a link and type in "www.google.com" > (without quotes) and the form turns it into "<a > href="www.google.com"></a>" (without the beginning and end quotes) and > displays that as text, so that they can copy/paste it into the forum > post box. It will also include an image-posting version so that it adds > the "<img src" etc to an image URL. > > How do I "quote" the result so that it displays as plain text rather > than a mess? All I'm getting is a mess of blue code. Nothing to do with PHP - this is an HTML. Look at your HTML source, and if you don't see the problem, try asking in alt.html. Once you find out what is wrong with your html, change your PHP code to fix the problem. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2011-05-20 09:34 +0200 |
| Message-ID | <ir55ie$ha3$1@dont-email.me> |
| In reply to | #1675 |
El 20/05/2011 0:31, Mentalguy2k8 escribió/wrote: > I'm trying to put together a little page with a form, so that users can > "translate" any URL into the correct format for posting on a forum. > > For instance, they want to share a link and type in "www.google.com" > (without quotes) and the form turns it into "<a > href="www.google.com"></a>" (without the beginning and end quotes) and > displays that as text, so that they can copy/paste it into the forum > post box. It will also include an image-posting version so that it adds > the "<img src" etc to an image URL. > > How do I "quote" the result so that it displays as plain text rather > than a mess? All I'm getting is a mess of blue code. The function to escape HTML is htmlspecialchars(): http://php.net/htmlspecialchars Make sure you use it every time you print arbitrary plain text, not only in this case. -- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://borrame.com -- Mi web de humor satinado: http://www.demogracia.com --
[toc] | [prev] | [next] | [standalone]
| From | "Mentalguy2k8" <Mentalguy2k8@gmail.com> |
|---|---|
| Date | 2011-05-20 09:44 +0100 |
| Message-ID | <ir59l6$6pj$1@dont-email.me> |
| In reply to | #1688 |
""Álvaro G. Vicario"" <alvaro.NOSPAMTHANX@demogracia.com.invalid> wrote in message news:ir55ie$ha3$1@dont-email.me... > El 20/05/2011 0:31, Mentalguy2k8 escribió/wrote: >> I'm trying to put together a little page with a form, so that users can >> "translate" any URL into the correct format for posting on a forum. >> >> For instance, they want to share a link and type in "www.google.com" >> (without quotes) and the form turns it into "<a >> href="www.google.com"></a>" (without the beginning and end quotes) and >> displays that as text, so that they can copy/paste it into the forum >> post box. It will also include an image-posting version so that it adds >> the "<img src" etc to an image URL. >> >> How do I "quote" the result so that it displays as plain text rather >> than a mess? All I'm getting is a mess of blue code. > > The function to escape HTML is htmlspecialchars(): > > http://php.net/htmlspecialchars > > Make sure you use it every time you print arbitrary plain text, not only > in this case. Thanks guys. I'm getting in a mess here... I've written the page where the user inputs the URL into a text box (as "url"), which passes the URL to the results page as follows: Cut and paste this link: <?php echo $_POST["url"]; ?> which will display the text "cut and paste this link" along with the URL that they entered. I need to add the <a href and the closing </a> around the URL, without spaces, so that the user can copy the entire line and paste it into the forum box.
[toc] | [prev] | [next] | [standalone]
| From | Michael Fesser <netizen@gmx.de> |
|---|---|
| Date | 2011-05-20 10:54 +0200 |
| Message-ID | <iqact6pduh5u0vduj6i9gttss0on477hr4@mfesser.de> |
| In reply to | #1690 |
.oO(Mentalguy2k8)
>I'm getting in a mess here... I've written the page where the user inputs
>the URL into a text box (as "url"), which passes the URL to the results page
>as follows:
>
>Cut and paste this link: <?php echo $_POST["url"]; ?>
>
>which will display the text "cut and paste this link" along with the URL
>that they entered. I need to add the <a href and the closing </a> around the
>URL, without spaces, so that the user can copy the entire line and paste it
>into the forum box.
<?php echo htmlspecialchars("<a href='{$_POST['url']}'></a>");?>
Something like that.
Micha
[toc] | [prev] | [next] | [standalone]
| From | Jeff North <jnorthau@yahoo.com.au> |
|---|---|
| Date | 2011-05-20 20:21 +1000 |
| Message-ID | <p3gct69n00naeh50sk4f7grl2t87a6g5qg@4ax.com> |
| In reply to | #1691 |
On Fri, 20 May 2011 10:54:07 +0200, in comp.lang.php Michael Fesser
<netizen@gmx.de>
<iqact6pduh5u0vduj6i9gttss0on477hr4@mfesser.de> wrote:
>| .oO(Mentalguy2k8)
>|
>| >I'm getting in a mess here... I've written the page where the user inputs
>| >the URL into a text box (as "url"), which passes the URL to the results page
>| >as follows:
>| >
>| >Cut and paste this link: <?php echo $_POST["url"]; ?>
>| >
>| >which will display the text "cut and paste this link" along with the URL
>| >that they entered. I need to add the <a href and the closing </a> around the
>| >URL, without spaces, so that the user can copy the entire line and paste it
>| >into the forum box.
>|
>| <?php echo htmlspecialchars("<a href='{$_POST['url']}'></a>");?>
>|
>| Something like that.
>|
>| Micha
So you get some text to show the link you will need:
<?php echo htmlspecialchars("<a
href='{$_POST['url']}'>{$_POST['url']}</a>");?>
[toc] | [prev] | [next] | [standalone]
| From | "Mentalguy2k8" <Mentalguy2k8@gmail.com> |
|---|---|
| Date | 2011-05-20 17:21 +0100 |
| Message-ID | <ir64dp$982$1@dont-email.me> |
| In reply to | #1693 |
"Jeff North" <jnorthau@yahoo.com.au> wrote in message
news:p3gct69n00naeh50sk4f7grl2t87a6g5qg@4ax.com...
> On Fri, 20 May 2011 10:54:07 +0200, in comp.lang.php Michael Fesser
> <netizen@gmx.de>
> <iqact6pduh5u0vduj6i9gttss0on477hr4@mfesser.de> wrote:
>
>>| .oO(Mentalguy2k8)
>>|
>>| >I'm getting in a mess here... I've written the page where the user
>>inputs
>>| >the URL into a text box (as "url"), which passes the URL to the results
>>page
>>| >as follows:
>>| >
>>| >Cut and paste this link: <?php echo $_POST["url"]; ?>
>>| >
>>| >which will display the text "cut and paste this link" along with the
>>URL
>>| >that they entered. I need to add the <a href and the closing </a>
>>around the
>>| >URL, without spaces, so that the user can copy the entire line and
>>paste it
>>| >into the forum box.
>>|
>>| <?php echo htmlspecialchars("<a href='{$_POST['url']}'></a>");?>
>>|
>>| Something like that.
>>|
>>| Micha
> So you get some text to show the link you will need:
> <?php echo htmlspecialchars("<a
> href='{$_POST['url']}'>{$_POST['url']}</a>");?>
Thanks a lot everyone, very useful and I got it working. Very much
appreciated, thanks again.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web