473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Angle brackets cause string to truncate

I am trying to build an email address in PHP code using v5.1.2. All
works well until I try to surround the email address with angle
brackets. Every method I try causes the email address to disappear
completely. I have to believe that this is a common problem, but I
can't find any answers in the PHP docs or in Google. Any insight
would be greatly appreciated. Below are some of my failed attempts.

$strAddressee = "$ContactName "."<"."$ContactEmail".">";
(brackets and email address disappear)

$strAddressee = "$ContactName <$ContactEmail>";
(brackets and email address disappear)

$strAddressee = "$ContactName \074 $ContactEmail \076";
(works, except for unwanted spaces between the brackets and address)

$strAddressee = "$ContactName \074{$ContactEmail}\076";
(brackets and email address disappear)

Apr 6 '07 #1
4 3938
>I am trying to build an email address in PHP code using v5.1.2. All
>works well until I try to surround the email address with angle
brackets.
Have you considered viewing the result in something other than HTML?
(or using the "view source" function of your browser?) I believe
the string really is there; you <dead catjust don't see it
<dead catin a browser <dead cat>. When you read this, how many
dead cats are there in the previous sentence? There are three.
>Every method I try causes the email address to disappear
completely. I have to believe that this is a common problem, but I
can't find any answers in the PHP docs or in Google. Any insight
would be greatly appreciated. Below are some of my failed attempts.

$strAddressee = "$ContactName "."<"."$ContactEmail".">";
(brackets and email address disappear)

$strAddressee = "$ContactName <$ContactEmail>";
(brackets and email address disappear)

$strAddressee = "$ContactName \074 $ContactEmail \076";
(works, except for unwanted spaces between the brackets and address)

$strAddressee = "$ContactName \074{$ContactEmail}\076";
(brackets and email address disappear)
If you want to output this string on a web page and *only* on a
web page, try:

$strAddressee = "$ContactName &lt;$ContactEmail&gt;";

but if you put that in mail headers it will probably screw up.
Apr 7 '07 #2
Gordon Burditt wrote:
>I am trying to build an email address in PHP code using v5.1.2. All
works well until I try to surround the email address with angle
brackets.

Have you considered viewing the result in something other than HTML?
(or using the "view source" function of your browser?) I believe
the string really is there; you <dead catjust don't see it
<dead catin a browser <dead cat>. When you read this, how many
dead cats are there in the previous sentence? There are three.
>Every method I try causes the email address to disappear
completely. I have to believe that this is a common problem, but I
can't find any answers in the PHP docs or in Google. Any insight
would be greatly appreciated. Below are some of my failed attempts.

$strAddressee = "$ContactName "."<"."$ContactEmail".">";
(brackets and email address disappear)

$strAddressee = "$ContactName <$ContactEmail>";
(brackets and email address disappear)

$strAddressee = "$ContactName \074 $ContactEmail \076";
(works, except for unwanted spaces between the brackets and address)

$strAddressee = "$ContactName \074{$ContactEmail}\076";
(brackets and email address disappear)

If you want to output this string on a web page and *only* on a
web page, try:

$strAddressee = "$ContactName &lt;$ContactEmail&gt;";

but if you put that in mail headers it will probably screw up.

or

$strAddressee = htmlspecialchars("$ContactName <$ContactEmail>");

Louise
Apr 7 '07 #3
Gordon Burditt wrote:
>I am trying to build an email address in PHP code using v5.1.2. All
works well until I try to surround the email address with angle
brackets.

Have you considered viewing the result in something other than HTML?
(or using the "view source" function of your browser?) I believe
the string really is there; you <dead catjust don't see it
<dead catin a browser <dead cat>. When you read this, how many
dead cats are there in the previous sentence? There are three.
>Every method I try causes the email address to disappear
completely. I have to believe that this is a common problem, but I
can't find any answers in the PHP docs or in Google. Any insight
would be greatly appreciated. Below are some of my failed attempts.

$strAddressee = "$ContactName "."<"."$ContactEmail".">";
(brackets and email address disappear)

$strAddressee = "$ContactName <$ContactEmail>";
(brackets and email address disappear)

$strAddressee = "$ContactName \074 $ContactEmail \076";
(works, except for unwanted spaces between the brackets and address)

$strAddressee = "$ContactName \074{$ContactEmail}\076";
(brackets and email address disappear)

If you want to output this string on a web page and *only* on a
web page, try:

$strAddressee = "$ContactName &lt;$ContactEmail&gt;";

but if you put that in mail headers it will probably screw up.

if you wanted to write out the strAddressee as debug on an html page and
it had the angle brackets in, you would have to do:

echo htmlentities($strAddressee);

That would encode the debug so you could see the angle brackets.
Apr 7 '07 #4
Have you considered viewing the result in something other than HTML?
(or using the "view source" function of your browser?) I believe
the string really is there; you <dead catjust don't see it
<dead catin a browser <dead cat>. When you read this, how many
dead cats are there in the previous sentence? There are three.
Nice catch Gordon! The address is there, just hidden. I was using
the browser to test the output, but the actual target is the mail()
function. It never occurred to me that the browser would interpret
the email address in brackets as an HTML tag. I guess what you see is
not always what you get. Thanks for your help, and thanks to the
other posters.

Apr 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mxsmanic | last post by:
I have a line like this in some PHP code on my Web page: $callthis =~ s/<*>//g; When the page runs, I get this error: Parse error: parse error, unexpected '<' in /Feedback.php on line 145 ...
5
by: Darren Grant | last post by:
Hi there, I've attempted to implement an Angle class. An Angle is a subset of an integer, where the range is [0,360). All other operations should be permitted. The code works, I think......
1
by: bartek | last post by:
Hi, I'm aware that both quoted and angle-bracketed strings in an #include directive result in implementation-defined file lookup, differing in the fact that #include "foo.h" first checks...
2
by: DotNetGruven | last post by:
We have a web service that returns a string which happens to be well formed XML. The client sees the string ok, except the angle brackets are HTML encoded ( &gt and &lt ). Is this expected...
29
by: Vol | last post by:
I think 'atan' can get the angle but it is not the four quadrant angle. Is there any function that i can get the angle from -pi to pi? or I have to use some if ... else? I know in Matlab, we use...
2
by: Kenneth Porter | last post by:
If you email your users links and wrap the links in angle brackets, beware users using Yahoo Mail. It includes the trailing angle bracket in the link, preventing it from working. (This was...
2
by: Peter | last post by:
Hi, I was wondering, can anyone tell me what statements in angle brackets are for in VB? For example, the default <System.Diagnostics.DebuggerStepThrough()thing that the IDE puts before the...
4
by: Keith Hughitt | last post by:
Hi all, I am using someone else's script which expects input in the form of: ./script.py <arg1arg2 I was wondering if the angle-brackets here have a special meaning? It seems like they...
6
by: jeffg | last post by:
I have created a site that uses a Doctype of XHTML Transitional and a character set of utf-8, in case any of this matters. I have validated every page and cleaned up all errors. IE displays the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.